@genai-fi/nanogpt 0.9.0 → 0.10.0
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 +82 -64
- 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/ops-LuCMAnmM.js
DELETED
|
@@ -1,1525 +0,0 @@
|
|
|
1
|
-
import { E as f, F as c, n as p, G as h, aS as Is, l as D, aT as Ss, aU as Ts, aV as xs, p as Ms, aW as M, w as ls, x as As, b as k, aX as gs, aY as ws, X as qs, ap as Ds, Q as K, aZ as Bs, a_ as Gs, a$ as zs, b0 as Os, b1 as Ls, b2 as Rs, b3 as Ws, b4 as Ks, b5 as vs, a0 as q, b6 as Vs, b7 as Cs, b8 as Ps, b9 as Ys, ba as js, aJ as Fs, bb as Us, t as Zs, bc as Q, bd as Hs, be as Xs, bf as Js, bg as Qs, bh as sn, bi as nn, bj as en, bk as tn, a as g, q as z, o as S, h as rn, c as d, bl as on, J as ss, d as an, a4 as O, z as cn } from "./index-BzFyqcy-.js";
|
|
2
|
-
import { t as w } from "./tensor1d-vML0r3q6.js";
|
|
3
|
-
import { n as un, a as ln, b as pn } from "./non_max_suppression_impl-CsEgBuMA.js";
|
|
4
|
-
import { r as y } from "./reshape-CnIwVG1c.js";
|
|
5
|
-
import { s as ds } from "./split-DK2k5eHf.js";
|
|
6
|
-
import { s as E } from "./sum-CJ0ULhmt.js";
|
|
7
|
-
import { b as ns } from "./broadcast_to-DzlNweb8.js";
|
|
8
|
-
import { s as x } from "./slice-d0Vo9XTN.js";
|
|
9
|
-
import { r as Z } from "./range-CWcz7xFA.js";
|
|
10
|
-
import { t as fn } from "./tensor-CZr4dh61.js";
|
|
11
|
-
import { s as H } from "./stack-DFatutCx.js";
|
|
12
|
-
import { c as mn, z as hn } from "./zeros-Bj5rMYA7.js";
|
|
13
|
-
import { e as $s } from "./axis_util-TbGYJ208.js";
|
|
14
|
-
import { m as es, a as ps, e as os, l as bn } from "./log_sum_exp-DO6z8tSE.js";
|
|
15
|
-
import { c as ts } from "./concat-B912vBbo.js";
|
|
16
|
-
import { m as G } from "./mat_mul-DzjTFx-u.js";
|
|
17
|
-
import { t as rs } from "./tensor2d-D76QGjF3.js";
|
|
18
|
-
import { o as gn } from "./ones-tIJeHlq-.js";
|
|
19
|
-
import { r as Es } from "./relu-BjCh_SYb.js";
|
|
20
|
-
/**
|
|
21
|
-
* @license
|
|
22
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
23
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
24
|
-
* you may not use this file except in compliance with the License.
|
|
25
|
-
* You may obtain a copy of the License at
|
|
26
|
-
*
|
|
27
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
-
*
|
|
29
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
-
* See the License for the specific language governing permissions and
|
|
33
|
-
* limitations under the License.
|
|
34
|
-
* =============================================================================
|
|
35
|
-
*/
|
|
36
|
-
function dn(e, r, s) {
|
|
37
|
-
const t = c(e, "x", "bincount"), n = c(r, "weights", "bincount");
|
|
38
|
-
p(t.dtype === "int32", () => `Error in bincount: input dtype must be int32, but got ${t.dtype}`), p(s >= 0, () => `size must be non-negative, but got ${s}.`), p(n.size === t.size || n.size === 0, () => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${t.shape}, weights shape: ${n.shape}.`);
|
|
39
|
-
const o = { x: t, weights: n }, a = { size: s };
|
|
40
|
-
return h.runKernel(Is, o, a);
|
|
41
|
-
}
|
|
42
|
-
const $n = /* @__PURE__ */ f({ bincount_: dn });
|
|
43
|
-
/**
|
|
44
|
-
* @license
|
|
45
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
46
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
47
|
-
* you may not use this file except in compliance with the License.
|
|
48
|
-
* You may obtain a copy of the License at
|
|
49
|
-
*
|
|
50
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
51
|
-
*
|
|
52
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
53
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
54
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
55
|
-
* See the License for the specific language governing permissions and
|
|
56
|
-
* limitations under the License.
|
|
57
|
-
* =============================================================================
|
|
58
|
-
*/
|
|
59
|
-
function En(e, r, s) {
|
|
60
|
-
const t = c(r, "a", "where"), n = c(s, "b", "where"), o = c(e, "condition", "where", "bool"), a = D(D(o.shape, t.shape), n.shape), i = ns(o, a), l = ns(t, a), u = ns(n, a), m = {
|
|
61
|
-
condition: i,
|
|
62
|
-
t: l,
|
|
63
|
-
e: u
|
|
64
|
-
};
|
|
65
|
-
return h.runKernel(Ss, m);
|
|
66
|
-
}
|
|
67
|
-
const v = /* @__PURE__ */ f({ where_: En });
|
|
68
|
-
/**
|
|
69
|
-
* @license
|
|
70
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
71
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
72
|
-
* you may not use this file except in compliance with the License.
|
|
73
|
-
* You may obtain a copy of the License at
|
|
74
|
-
*
|
|
75
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
76
|
-
*
|
|
77
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
78
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
79
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
80
|
-
* See the License for the specific language governing permissions and
|
|
81
|
-
* limitations under the License.
|
|
82
|
-
* =============================================================================
|
|
83
|
-
*/
|
|
84
|
-
function _n(e, ...r) {
|
|
85
|
-
const s = r.map((n, o) => c(n, `tensors${o}`, "einsum")), t = { equation: e };
|
|
86
|
-
return h.runKernel(Ts, s, t);
|
|
87
|
-
}
|
|
88
|
-
const P = /* @__PURE__ */ f({ einsum_: _n });
|
|
89
|
-
/**
|
|
90
|
-
* @license
|
|
91
|
-
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
92
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
93
|
-
* you may not use this file except in compliance with the License.
|
|
94
|
-
* You may obtain a copy of the License at
|
|
95
|
-
*
|
|
96
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
97
|
-
*
|
|
98
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
99
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
100
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
101
|
-
* See the License for the specific language governing permissions and
|
|
102
|
-
* limitations under the License.
|
|
103
|
-
* =============================================================================
|
|
104
|
-
*/
|
|
105
|
-
function kn(e, r = null, s = !1) {
|
|
106
|
-
const n = { x: c(e, "x", "min") }, o = { axis: r, keepDims: s };
|
|
107
|
-
return h.runKernel(xs, n, o);
|
|
108
|
-
}
|
|
109
|
-
const fs = /* @__PURE__ */ f({ min_: kn });
|
|
110
|
-
/**
|
|
111
|
-
* @license
|
|
112
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
113
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
114
|
-
* you may not use this file except in compliance with the License.
|
|
115
|
-
* You may obtain a copy of the License at
|
|
116
|
-
*
|
|
117
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
118
|
-
*
|
|
119
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
120
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
121
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
122
|
-
* See the License for the specific language governing permissions and
|
|
123
|
-
* limitations under the License.
|
|
124
|
-
* =============================================================================
|
|
125
|
-
*/
|
|
126
|
-
function yn(e, r = "euclidean", s = null, t = !1) {
|
|
127
|
-
e = c(e, "x", "norm");
|
|
128
|
-
const n = _s(e, r, s);
|
|
129
|
-
let o = n.shape;
|
|
130
|
-
if (t) {
|
|
131
|
-
const a = Ms(s, e.shape);
|
|
132
|
-
o = $s(n.shape, a);
|
|
133
|
-
}
|
|
134
|
-
return y(n, o);
|
|
135
|
-
}
|
|
136
|
-
function _s(e, r, s = null) {
|
|
137
|
-
if (e.rank === 0)
|
|
138
|
-
return M(e);
|
|
139
|
-
if (e.rank !== 1 && s === null)
|
|
140
|
-
return _s(y(e, [-1]), r, s);
|
|
141
|
-
if (e.rank === 1 || typeof s == "number" || Array.isArray(s) && s.length === 1) {
|
|
142
|
-
if (r === 1)
|
|
143
|
-
return E(M(e), s);
|
|
144
|
-
if (r === 1 / 0)
|
|
145
|
-
return es(M(e), s);
|
|
146
|
-
if (r === -1 / 0)
|
|
147
|
-
return fs(M(e), s);
|
|
148
|
-
if (r === "euclidean" || r === 2)
|
|
149
|
-
return ls(E(As(M(e), k(2, "int32")), s));
|
|
150
|
-
throw new Error(`Error in norm: invalid ord value: ${r}`);
|
|
151
|
-
}
|
|
152
|
-
if (Array.isArray(s) && s.length === 2) {
|
|
153
|
-
if (r === 1)
|
|
154
|
-
return es(E(M(e), s[0]), s[1] - 1);
|
|
155
|
-
if (r === 1 / 0)
|
|
156
|
-
return es(E(M(e), s[1]), s[0]);
|
|
157
|
-
if (r === -1 / 0)
|
|
158
|
-
return fs(E(M(e), s[1]), s[0]);
|
|
159
|
-
if (r === "fro" || r === "euclidean")
|
|
160
|
-
return ls(E(gs(e), s));
|
|
161
|
-
throw new Error(`Error in norm: invalid ord value: ${r}`);
|
|
162
|
-
}
|
|
163
|
-
throw new Error(`Error in norm: invalid axis: ${s}`);
|
|
164
|
-
}
|
|
165
|
-
const ks = /* @__PURE__ */ f({ norm_: yn });
|
|
166
|
-
/**
|
|
167
|
-
* @license
|
|
168
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
169
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
170
|
-
* you may not use this file except in compliance with the License.
|
|
171
|
-
* You may obtain a copy of the License at
|
|
172
|
-
*
|
|
173
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
174
|
-
*
|
|
175
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
176
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
177
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
178
|
-
* See the License for the specific language governing permissions and
|
|
179
|
-
* limitations under the License.
|
|
180
|
-
* =============================================================================
|
|
181
|
-
*/
|
|
182
|
-
function Nn(e, r = 0) {
|
|
183
|
-
const s = c(e, "x", "expandDims", "string_or_numeric");
|
|
184
|
-
p(r <= s.rank, () => "Axis must be <= rank of the tensor");
|
|
185
|
-
const t = { input: s }, n = { dim: r };
|
|
186
|
-
return h.runKernel(ws, t, n);
|
|
187
|
-
}
|
|
188
|
-
const W = /* @__PURE__ */ f({ expandDims_: Nn });
|
|
189
|
-
/**
|
|
190
|
-
* @license
|
|
191
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
192
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
* you may not use this file except in compliance with the License.
|
|
194
|
-
* You may obtain a copy of the License at
|
|
195
|
-
*
|
|
196
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
*
|
|
198
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
* See the License for the specific language governing permissions and
|
|
202
|
-
* limitations under the License.
|
|
203
|
-
* =============================================================================
|
|
204
|
-
*/
|
|
205
|
-
function In(e, r) {
|
|
206
|
-
const s = c(e, "x", "tile", "string_or_numeric");
|
|
207
|
-
p(s.rank === r.length, () => `Error in transpose: rank of input ${s.rank} must match length of reps ${r}.`);
|
|
208
|
-
const t = { x: s }, n = { reps: r };
|
|
209
|
-
return h.runKernel(qs, t, n);
|
|
210
|
-
}
|
|
211
|
-
const U = /* @__PURE__ */ f({ tile_: In });
|
|
212
|
-
/**
|
|
213
|
-
* @license
|
|
214
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
215
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
216
|
-
* you may not use this file except in compliance with the License.
|
|
217
|
-
* You may obtain a copy of the License at
|
|
218
|
-
*
|
|
219
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
220
|
-
*
|
|
221
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
222
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
223
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
224
|
-
* See the License for the specific language governing permissions and
|
|
225
|
-
* limitations under the License.
|
|
226
|
-
* =============================================================================
|
|
227
|
-
*/
|
|
228
|
-
function Sn(e, r, s, t = "float32") {
|
|
229
|
-
r == null && (r = e);
|
|
230
|
-
const n = Ds([e, r], t), o = e <= r ? e : r;
|
|
231
|
-
for (let i = 0; i < o; ++i)
|
|
232
|
-
n.set(1, i, i);
|
|
233
|
-
const a = y(n.toTensor(), [e, r]);
|
|
234
|
-
if (s == null)
|
|
235
|
-
return a;
|
|
236
|
-
if (s.length === 1)
|
|
237
|
-
return U(W(a, 0), [s[0], 1, 1]);
|
|
238
|
-
if (s.length === 2)
|
|
239
|
-
return U(W(W(a, 0), 0), [s[0], s[1], 1, 1]);
|
|
240
|
-
if (s.length === 3)
|
|
241
|
-
return U(W(W(W(a, 0), 0), 0), [
|
|
242
|
-
s[0],
|
|
243
|
-
s[1],
|
|
244
|
-
s[2],
|
|
245
|
-
1,
|
|
246
|
-
1
|
|
247
|
-
]);
|
|
248
|
-
throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${s.length}D.`);
|
|
249
|
-
}
|
|
250
|
-
const Tn = /* @__PURE__ */ f({ eye_: Sn });
|
|
251
|
-
/**
|
|
252
|
-
* @license
|
|
253
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
254
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
255
|
-
* you may not use this file except in compliance with the License.
|
|
256
|
-
* You may obtain a copy of the License at
|
|
257
|
-
*
|
|
258
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
259
|
-
*
|
|
260
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
261
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
262
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
263
|
-
* See the License for the specific language governing permissions and
|
|
264
|
-
* limitations under the License.
|
|
265
|
-
* =============================================================================
|
|
266
|
-
*/
|
|
267
|
-
function xn(e, r) {
|
|
268
|
-
let s = c(e, "a", "greater", "string_or_numeric"), t = c(r, "b", "greater", "string_or_numeric");
|
|
269
|
-
[s, t] = K(s, t), D(s.shape, t.shape);
|
|
270
|
-
const n = { a: s, b: t };
|
|
271
|
-
return h.runKernel(Bs, n);
|
|
272
|
-
}
|
|
273
|
-
const is = /* @__PURE__ */ f({ greater_: xn });
|
|
274
|
-
/**
|
|
275
|
-
* @license
|
|
276
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
277
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
278
|
-
* you may not use this file except in compliance with the License.
|
|
279
|
-
* You may obtain a copy of the License at
|
|
280
|
-
*
|
|
281
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
282
|
-
*
|
|
283
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
284
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
285
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
286
|
-
* See the License for the specific language governing permissions and
|
|
287
|
-
* limitations under the License.
|
|
288
|
-
* =============================================================================
|
|
289
|
-
*/
|
|
290
|
-
function Mn(e, r) {
|
|
291
|
-
let s = c(e, "a", "greaterEqual", "string_or_numeric"), t = c(r, "b", "greaterEqual", "string_or_numeric");
|
|
292
|
-
[s, t] = K(s, t), D(s.shape, t.shape);
|
|
293
|
-
const n = { a: s, b: t };
|
|
294
|
-
return h.runKernel(Gs, n);
|
|
295
|
-
}
|
|
296
|
-
const An = /* @__PURE__ */ f({ greaterEqual_: Mn });
|
|
297
|
-
/**
|
|
298
|
-
* @license
|
|
299
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
300
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
301
|
-
* you may not use this file except in compliance with the License.
|
|
302
|
-
* You may obtain a copy of the License at
|
|
303
|
-
*
|
|
304
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
305
|
-
*
|
|
306
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
307
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
308
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
309
|
-
* See the License for the specific language governing permissions and
|
|
310
|
-
* limitations under the License.
|
|
311
|
-
* =============================================================================
|
|
312
|
-
*/
|
|
313
|
-
function wn(e) {
|
|
314
|
-
const s = { input: c(e, "input", "imag") };
|
|
315
|
-
return h.runKernel(zs, s);
|
|
316
|
-
}
|
|
317
|
-
const qn = /* @__PURE__ */ f({ imag_: wn });
|
|
318
|
-
/**
|
|
319
|
-
* @license
|
|
320
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
321
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
322
|
-
* you may not use this file except in compliance with the License.
|
|
323
|
-
* You may obtain a copy of the License at
|
|
324
|
-
*
|
|
325
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
326
|
-
*
|
|
327
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
328
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
329
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
330
|
-
* See the License for the specific language governing permissions and
|
|
331
|
-
* limitations under the License.
|
|
332
|
-
* =============================================================================
|
|
333
|
-
*/
|
|
334
|
-
function Dn(e, r) {
|
|
335
|
-
let s = c(e, "a", "less", "string_or_numeric"), t = c(r, "b", "less", "string_or_numeric");
|
|
336
|
-
[s, t] = K(s, t), D(s.shape, t.shape);
|
|
337
|
-
const n = { a: s, b: t };
|
|
338
|
-
return h.runKernel(Os, n);
|
|
339
|
-
}
|
|
340
|
-
const ms = /* @__PURE__ */ f({ less_: Dn });
|
|
341
|
-
/**
|
|
342
|
-
* @license
|
|
343
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
344
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
345
|
-
* you may not use this file except in compliance with the License.
|
|
346
|
-
* You may obtain a copy of the License at
|
|
347
|
-
*
|
|
348
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
349
|
-
*
|
|
350
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
351
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
352
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
353
|
-
* See the License for the specific language governing permissions and
|
|
354
|
-
* limitations under the License.
|
|
355
|
-
* =============================================================================
|
|
356
|
-
*/
|
|
357
|
-
function Bn(e, r) {
|
|
358
|
-
let s = c(e, "a", "lessEqual", "string_or_numeric"), t = c(r, "b", "lessEqual", "string_or_numeric");
|
|
359
|
-
[s, t] = K(s, t), D(s.shape, t.shape);
|
|
360
|
-
const n = { a: s, b: t };
|
|
361
|
-
return h.runKernel(Ls, n);
|
|
362
|
-
}
|
|
363
|
-
const ys = /* @__PURE__ */ f({ lessEqual_: Bn });
|
|
364
|
-
/**
|
|
365
|
-
* @license
|
|
366
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
367
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
368
|
-
* you may not use this file except in compliance with the License.
|
|
369
|
-
* You may obtain a copy of the License at
|
|
370
|
-
*
|
|
371
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
372
|
-
*
|
|
373
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
374
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
375
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
376
|
-
* See the License for the specific language governing permissions and
|
|
377
|
-
* limitations under the License.
|
|
378
|
-
* =============================================================================
|
|
379
|
-
*/
|
|
380
|
-
function Gn(e) {
|
|
381
|
-
const s = { x: c(e, "x", "log1p") };
|
|
382
|
-
return h.runKernel(Rs, s);
|
|
383
|
-
}
|
|
384
|
-
const zn = /* @__PURE__ */ f({ log1p_: Gn });
|
|
385
|
-
/**
|
|
386
|
-
* @license
|
|
387
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
388
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
389
|
-
* you may not use this file except in compliance with the License.
|
|
390
|
-
* You may obtain a copy of the License at
|
|
391
|
-
*
|
|
392
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
393
|
-
*
|
|
394
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
395
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
396
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
397
|
-
* See the License for the specific language governing permissions and
|
|
398
|
-
* limitations under the License.
|
|
399
|
-
* =============================================================================
|
|
400
|
-
*/
|
|
401
|
-
function On(e) {
|
|
402
|
-
const s = { x: c(e, "x", "neg") };
|
|
403
|
-
return h.runKernel(Ws, s);
|
|
404
|
-
}
|
|
405
|
-
const V = /* @__PURE__ */ f({ neg_: On });
|
|
406
|
-
/**
|
|
407
|
-
* @license
|
|
408
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
409
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
410
|
-
* you may not use this file except in compliance with the License.
|
|
411
|
-
* You may obtain a copy of the License at
|
|
412
|
-
*
|
|
413
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
414
|
-
*
|
|
415
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
416
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
417
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
418
|
-
* See the License for the specific language governing permissions and
|
|
419
|
-
* limitations under the License.
|
|
420
|
-
* =============================================================================
|
|
421
|
-
*/
|
|
422
|
-
function Ln(e, r) {
|
|
423
|
-
const s = c(e, "a", "logicalAnd", "bool"), t = c(r, "b", "logicalAnd", "bool");
|
|
424
|
-
D(s.shape, t.shape);
|
|
425
|
-
const n = { a: s, b: t };
|
|
426
|
-
return h.runKernel(Ks, n);
|
|
427
|
-
}
|
|
428
|
-
const Rn = /* @__PURE__ */ f({ logicalAnd_: Ln });
|
|
429
|
-
/**
|
|
430
|
-
* @license
|
|
431
|
-
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
432
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
433
|
-
* you may not use this file except in compliance with the License.
|
|
434
|
-
* You may obtain a copy of the License at
|
|
435
|
-
*
|
|
436
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
437
|
-
*
|
|
438
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
439
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
440
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
441
|
-
* See the License for the specific language governing permissions and
|
|
442
|
-
* limitations under the License.
|
|
443
|
-
* =============================================================================
|
|
444
|
-
*/
|
|
445
|
-
function Wn(e, r = null, s = !1) {
|
|
446
|
-
const n = { x: c(e, "x", "mean") }, o = { axis: r, keepDims: s };
|
|
447
|
-
return h.runKernel(vs, n, o);
|
|
448
|
-
}
|
|
449
|
-
const Kn = /* @__PURE__ */ f({ mean_: Wn });
|
|
450
|
-
/**
|
|
451
|
-
* @license
|
|
452
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
453
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
454
|
-
* you may not use this file except in compliance with the License.
|
|
455
|
-
* You may obtain a copy of the License at
|
|
456
|
-
*
|
|
457
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
458
|
-
*
|
|
459
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
460
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
461
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
462
|
-
* See the License for the specific language governing permissions and
|
|
463
|
-
* limitations under the License.
|
|
464
|
-
* =============================================================================
|
|
465
|
-
*/
|
|
466
|
-
function vn(e, r) {
|
|
467
|
-
let s = c(e, "a", "minimum"), t = c(r, "b", "minimum");
|
|
468
|
-
[s, t] = K(s, t), s.dtype === "bool" && (s = q(s, "int32"), t = q(t, "int32")), D(s.shape, t.shape);
|
|
469
|
-
const n = { a: s, b: t };
|
|
470
|
-
return h.runKernel(Vs, n);
|
|
471
|
-
}
|
|
472
|
-
const as = /* @__PURE__ */ f({ minimum_: vn });
|
|
473
|
-
/**
|
|
474
|
-
* @license
|
|
475
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
476
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
477
|
-
* you may not use this file except in compliance with the License.
|
|
478
|
-
* You may obtain a copy of the License at
|
|
479
|
-
*
|
|
480
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
481
|
-
*
|
|
482
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
483
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
484
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
485
|
-
* See the License for the specific language governing permissions and
|
|
486
|
-
* limitations under the License.
|
|
487
|
-
* =============================================================================
|
|
488
|
-
*/
|
|
489
|
-
function Vn(e, r) {
|
|
490
|
-
let s = c(e, "a", "notEqual", "string_or_numeric"), t = c(r, "b", "notEqual", "string_or_numeric");
|
|
491
|
-
[s, t] = K(s, t), D(s.shape, t.shape);
|
|
492
|
-
const n = { a: s, b: t };
|
|
493
|
-
return h.runKernel(Cs, n);
|
|
494
|
-
}
|
|
495
|
-
const Cn = /* @__PURE__ */ f({ notEqual_: Vn });
|
|
496
|
-
/**
|
|
497
|
-
* @license
|
|
498
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
499
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
500
|
-
* you may not use this file except in compliance with the License.
|
|
501
|
-
* You may obtain a copy of the License at
|
|
502
|
-
*
|
|
503
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
504
|
-
*
|
|
505
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
506
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
507
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
508
|
-
* See the License for the specific language governing permissions and
|
|
509
|
-
* limitations under the License.
|
|
510
|
-
* =============================================================================
|
|
511
|
-
*/
|
|
512
|
-
function Pn(e) {
|
|
513
|
-
const s = { input: c(e, "input", "real") };
|
|
514
|
-
return h.runKernel(Ps, s);
|
|
515
|
-
}
|
|
516
|
-
const Yn = /* @__PURE__ */ f({ real_: Pn });
|
|
517
|
-
/**
|
|
518
|
-
* @license
|
|
519
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
520
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
521
|
-
* you may not use this file except in compliance with the License.
|
|
522
|
-
* You may obtain a copy of the License at
|
|
523
|
-
*
|
|
524
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
525
|
-
*
|
|
526
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
527
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
528
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
529
|
-
* See the License for the specific language governing permissions and
|
|
530
|
-
* limitations under the License.
|
|
531
|
-
* =============================================================================
|
|
532
|
-
*/
|
|
533
|
-
function jn(e) {
|
|
534
|
-
const s = { x: c(e, "x", "round") };
|
|
535
|
-
return h.runKernel(Ys, s);
|
|
536
|
-
}
|
|
537
|
-
const Fn = /* @__PURE__ */ f({ round_: jn });
|
|
538
|
-
/**
|
|
539
|
-
* @license
|
|
540
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
541
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
542
|
-
* you may not use this file except in compliance with the License.
|
|
543
|
-
* You may obtain a copy of the License at
|
|
544
|
-
*
|
|
545
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
546
|
-
*
|
|
547
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
548
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
549
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
550
|
-
* See the License for the specific language governing permissions and
|
|
551
|
-
* limitations under the License.
|
|
552
|
-
* =============================================================================
|
|
553
|
-
*/
|
|
554
|
-
function Un(e, r) {
|
|
555
|
-
let s = c(e, "a", "squaredDifference"), t = c(r, "b", "squaredDifference");
|
|
556
|
-
[s, t] = K(s, t), D(s.shape, t.shape);
|
|
557
|
-
const n = { a: s, b: t }, o = {};
|
|
558
|
-
return h.runKernel(js, n, o);
|
|
559
|
-
}
|
|
560
|
-
const Zn = /* @__PURE__ */ f({ squaredDifference_: Un });
|
|
561
|
-
/**
|
|
562
|
-
* @license
|
|
563
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
564
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
565
|
-
* you may not use this file except in compliance with the License.
|
|
566
|
-
* You may obtain a copy of the License at
|
|
567
|
-
*
|
|
568
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
569
|
-
*
|
|
570
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
571
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
572
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
573
|
-
* See the License for the specific language governing permissions and
|
|
574
|
-
* limitations under the License.
|
|
575
|
-
* =============================================================================
|
|
576
|
-
*/
|
|
577
|
-
function Hn(e, r) {
|
|
578
|
-
const s = c(e, "x", "squeeze", "string_or_numeric");
|
|
579
|
-
return y(s, Fs(s.shape, r).newShape);
|
|
580
|
-
}
|
|
581
|
-
const Xn = /* @__PURE__ */ f({ squeeze_: Hn });
|
|
582
|
-
/**
|
|
583
|
-
* @license
|
|
584
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
585
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
586
|
-
* you may not use this file except in compliance with the License.
|
|
587
|
-
* You may obtain a copy of the License at
|
|
588
|
-
*
|
|
589
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
590
|
-
*
|
|
591
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
592
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
593
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
594
|
-
* See the License for the specific language governing permissions and
|
|
595
|
-
* limitations under the License.
|
|
596
|
-
* =============================================================================
|
|
597
|
-
*/
|
|
598
|
-
function Jn(e, r = 0) {
|
|
599
|
-
const s = c(e, "x", "unstack", "string_or_numeric");
|
|
600
|
-
p(r >= -s.shape.length && r < s.shape.length, () => `Axis = ${r} is not in [-${s.shape.length}, ${s.shape.length})`);
|
|
601
|
-
const t = { value: s }, n = { axis: r };
|
|
602
|
-
return h.runKernel(Us, t, n);
|
|
603
|
-
}
|
|
604
|
-
const Ns = /* @__PURE__ */ f({ unstack_: Jn });
|
|
605
|
-
/**
|
|
606
|
-
* @license
|
|
607
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
608
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
609
|
-
* you may not use this file except in compliance with the License.
|
|
610
|
-
* You may obtain a copy of the License at
|
|
611
|
-
*
|
|
612
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
613
|
-
*
|
|
614
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
615
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
616
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
617
|
-
* See the License for the specific language governing permissions and
|
|
618
|
-
* limitations under the License.
|
|
619
|
-
* =============================================================================
|
|
620
|
-
*/
|
|
621
|
-
function Qn(e, r, s) {
|
|
622
|
-
const t = c(e, "x", "transpose");
|
|
623
|
-
if (r == null && (r = t.shape.map((a, i) => i).reverse()), p(t.rank === r.length, () => `Error in transpose: rank of input ${t.rank} must match length of perm ${r}.`), r.forEach((a) => {
|
|
624
|
-
p(a >= 0 && a < t.rank, () => `All entries in 'perm' must be between 0 and ${t.rank - 1} but got ${r}`);
|
|
625
|
-
}), t.rank <= 1)
|
|
626
|
-
return t.clone();
|
|
627
|
-
const n = { x: t }, o = { perm: r };
|
|
628
|
-
return t.dtype === "complex64" ? Zs(() => {
|
|
629
|
-
let a = Yn(t), i = qn(t);
|
|
630
|
-
return a = h.runKernel(Q, { x: a }, o), i = h.runKernel(Q, { x: i }, o), s && (i = V(i)), mn(a, i);
|
|
631
|
-
}) : h.runKernel(Q, n, o);
|
|
632
|
-
}
|
|
633
|
-
const hs = /* @__PURE__ */ f({ transpose_: Qn });
|
|
634
|
-
/**
|
|
635
|
-
* @license
|
|
636
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
637
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
638
|
-
* you may not use this file except in compliance with the License.
|
|
639
|
-
* You may obtain a copy of the License at
|
|
640
|
-
*
|
|
641
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
642
|
-
*
|
|
643
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
644
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
645
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
646
|
-
* See the License for the specific language governing permissions and
|
|
647
|
-
* limitations under the License.
|
|
648
|
-
* =============================================================================
|
|
649
|
-
*/
|
|
650
|
-
function se(e, r, s, t, n = "bilinear", o = 0) {
|
|
651
|
-
const a = c(e, "image", "cropAndResize"), i = c(r, "boxes", "cropAndResize", "float32"), l = c(s, "boxInd", "cropAndResize", "int32"), u = i.shape[0];
|
|
652
|
-
p(a.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${a.rank}.`), p(i.rank === 2 && i.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${u},4] but had shape ${i.shape}.`), p(l.rank === 1 && l.shape[0] === u, () => `Error in cropAndResize: boxInd must be have size [${u}] but had shape ${i.shape}.`), p(t.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${t.length}.`), p(t[0] >= 1 && t[1] >= 1, () => `cropSize must be atleast [1,1], but was ${t}`), p(n === "bilinear" || n === "nearest", () => `method must be bilinear or nearest, but was ${n}`);
|
|
653
|
-
const m = { image: a, boxes: i, boxInd: l }, b = { method: n, extrapolationValue: o, cropSize: t };
|
|
654
|
-
return h.runKernel(Hs, m, b);
|
|
655
|
-
}
|
|
656
|
-
const ne = /* @__PURE__ */ f({ cropAndResize_: se });
|
|
657
|
-
/**
|
|
658
|
-
* @license
|
|
659
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
660
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
661
|
-
* you may not use this file except in compliance with the License.
|
|
662
|
-
* You may obtain a copy of the License at
|
|
663
|
-
*
|
|
664
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
665
|
-
*
|
|
666
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
667
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
668
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
669
|
-
* See the License for the specific language governing permissions and
|
|
670
|
-
* limitations under the License.
|
|
671
|
-
* =============================================================================
|
|
672
|
-
*/
|
|
673
|
-
function ee(e) {
|
|
674
|
-
const r = c(e, "image", "flipLeftRight", "float32");
|
|
675
|
-
p(r.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${r.rank}.`);
|
|
676
|
-
const s = { image: r };
|
|
677
|
-
return h.runKernel(Xs, s, {});
|
|
678
|
-
}
|
|
679
|
-
const te = /* @__PURE__ */ f({ flipLeftRight_: ee });
|
|
680
|
-
/**
|
|
681
|
-
* @license
|
|
682
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
683
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
684
|
-
* you may not use this file except in compliance with the License.
|
|
685
|
-
* You may obtain a copy of the License at
|
|
686
|
-
*
|
|
687
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
688
|
-
*
|
|
689
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
690
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
691
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
692
|
-
* See the License for the specific language governing permissions and
|
|
693
|
-
* limitations under the License.
|
|
694
|
-
* =============================================================================
|
|
695
|
-
*/
|
|
696
|
-
function re(e) {
|
|
697
|
-
const r = c(e, "image", "grayscaleToRGB"), s = r.rank - 1, t = r.shape[s];
|
|
698
|
-
p(r.rank >= 2, () => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${r.rank}.`), p(t === 1, () => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${t}.`);
|
|
699
|
-
const n = new Array(r.rank);
|
|
700
|
-
return n.fill(1, 0, s), n[s] = 3, U(r, n);
|
|
701
|
-
}
|
|
702
|
-
const oe = /* @__PURE__ */ f({ grayscaleToRGB_: re });
|
|
703
|
-
/**
|
|
704
|
-
* @license
|
|
705
|
-
* Copyright 2023 Google LLC.
|
|
706
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
707
|
-
* you may not use this file except in compliance with the License.
|
|
708
|
-
* You may obtain a copy of the License at
|
|
709
|
-
*
|
|
710
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
711
|
-
*
|
|
712
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
713
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
714
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
715
|
-
* See the License for the specific language governing permissions and
|
|
716
|
-
* limitations under the License.
|
|
717
|
-
* =============================================================================
|
|
718
|
-
*/
|
|
719
|
-
function ae(e) {
|
|
720
|
-
const r = c(e, "image", "RGBToGrayscale"), s = r.rank - 1, t = r.shape[s];
|
|
721
|
-
p(r.rank >= 2, () => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${r.rank}.`), p(t === 3, () => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${t}.`);
|
|
722
|
-
const n = r.dtype, o = q(r, "float32"), a = w([0.2989, 0.587, 0.114]);
|
|
723
|
-
let i;
|
|
724
|
-
switch (r.rank) {
|
|
725
|
-
case 2:
|
|
726
|
-
i = P("ij,j->i", o, a);
|
|
727
|
-
break;
|
|
728
|
-
case 3:
|
|
729
|
-
i = P("ijk,k->ij", o, a);
|
|
730
|
-
break;
|
|
731
|
-
case 4:
|
|
732
|
-
i = P("ijkl,l->ijk", o, a);
|
|
733
|
-
break;
|
|
734
|
-
case 5:
|
|
735
|
-
i = P("ijklm,m->ijkl", o, a);
|
|
736
|
-
break;
|
|
737
|
-
case 6:
|
|
738
|
-
i = P("ijklmn,n->ijklm", o, a);
|
|
739
|
-
break;
|
|
740
|
-
default:
|
|
741
|
-
throw new Error("Not a valid tensor rank.");
|
|
742
|
-
}
|
|
743
|
-
return i = W(i, -1), q(i, n);
|
|
744
|
-
}
|
|
745
|
-
const ie = /* @__PURE__ */ f({ rgbToGrayscale_: ae });
|
|
746
|
-
/**
|
|
747
|
-
* @license
|
|
748
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
749
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
750
|
-
* you may not use this file except in compliance with the License.
|
|
751
|
-
* You may obtain a copy of the License at
|
|
752
|
-
*
|
|
753
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
754
|
-
*
|
|
755
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
756
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
757
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
758
|
-
* See the License for the specific language governing permissions and
|
|
759
|
-
* limitations under the License.
|
|
760
|
-
* =============================================================================
|
|
761
|
-
*/
|
|
762
|
-
function ce(e, r, s = 0, t = 0.5) {
|
|
763
|
-
const n = c(e, "image", "rotateWithOffset", "float32");
|
|
764
|
-
p(n.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${n.rank}.`);
|
|
765
|
-
const o = { image: n }, a = { radians: r, fillValue: s, center: t };
|
|
766
|
-
return h.runKernel(Js, o, a);
|
|
767
|
-
}
|
|
768
|
-
const ue = /* @__PURE__ */ f({ rotateWithOffset_: ce });
|
|
769
|
-
/**
|
|
770
|
-
* @license
|
|
771
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
772
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
773
|
-
* you may not use this file except in compliance with the License.
|
|
774
|
-
* You may obtain a copy of the License at
|
|
775
|
-
*
|
|
776
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
777
|
-
*
|
|
778
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
779
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
780
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
781
|
-
* See the License for the specific language governing permissions and
|
|
782
|
-
* limitations under the License.
|
|
783
|
-
* =============================================================================
|
|
784
|
-
*/
|
|
785
|
-
function C(e, r, s, t, n, o) {
|
|
786
|
-
t == null && (t = 0.5), n == null && (n = Number.NEGATIVE_INFINITY), o == null && (o = 0);
|
|
787
|
-
const a = e.shape[0];
|
|
788
|
-
return s = Math.min(s, a), p(0 <= t && t <= 1, () => `iouThreshold must be in [0, 1], but was '${t}'`), p(e.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${e.rank}'`), p(e.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`), p(r.rank === 1, () => "scores must be a 1D tensor"), p(r.shape[0] === a, () => `scores has incompatible shape with boxes. Expected ${a}, but was ${r.shape[0]}`), p(0 <= o && o <= 1, () => `softNmsSigma must be in [0, 1], but was '${o}'`), { maxOutputSize: s, iouThreshold: t, scoreThreshold: n, softNmsSigma: o };
|
|
789
|
-
}
|
|
790
|
-
/**
|
|
791
|
-
* @license
|
|
792
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
793
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
794
|
-
* you may not use this file except in compliance with the License.
|
|
795
|
-
* You may obtain a copy of the License at
|
|
796
|
-
*
|
|
797
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
798
|
-
*
|
|
799
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
800
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
801
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
802
|
-
* See the License for the specific language governing permissions and
|
|
803
|
-
* limitations under the License.
|
|
804
|
-
* =============================================================================
|
|
805
|
-
*/
|
|
806
|
-
function le(e, r, s, t = 0.5, n = Number.NEGATIVE_INFINITY) {
|
|
807
|
-
const o = c(e, "boxes", "nonMaxSuppression", "float32"), a = c(r, "scores", "nonMaxSuppression", "float32"), i = C(o, a, s, t, n);
|
|
808
|
-
s = i.maxOutputSize, t = i.iouThreshold, n = i.scoreThreshold;
|
|
809
|
-
const l = { maxOutputSize: s, iouThreshold: t, scoreThreshold: n };
|
|
810
|
-
return h.runKernel(Qs, { boxes: o, scores: a }, l);
|
|
811
|
-
}
|
|
812
|
-
const pe = /* @__PURE__ */ f({ nonMaxSuppression_: le });
|
|
813
|
-
/**
|
|
814
|
-
* @license
|
|
815
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
816
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
817
|
-
* you may not use this file except in compliance with the License.
|
|
818
|
-
* You may obtain a copy of the License at
|
|
819
|
-
*
|
|
820
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
821
|
-
*
|
|
822
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
823
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
824
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
825
|
-
* See the License for the specific language governing permissions and
|
|
826
|
-
* limitations under the License.
|
|
827
|
-
* =============================================================================
|
|
828
|
-
*/
|
|
829
|
-
async function fe(e, r, s, t = 0.5, n = Number.NEGATIVE_INFINITY) {
|
|
830
|
-
const o = c(e, "boxes", "nonMaxSuppressionAsync"), a = c(r, "scores", "nonMaxSuppressionAsync"), i = C(o, a, s, t, n);
|
|
831
|
-
s = i.maxOutputSize, t = i.iouThreshold, n = i.scoreThreshold;
|
|
832
|
-
const l = await Promise.all([o.data(), a.data()]), u = l[0], m = l[1], { selectedIndices: b } = un(u, m, s, t, n);
|
|
833
|
-
return o !== e && o.dispose(), a !== r && a.dispose(), w(b, "int32");
|
|
834
|
-
}
|
|
835
|
-
const me = fe;
|
|
836
|
-
/**
|
|
837
|
-
* @license
|
|
838
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
839
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
840
|
-
* you may not use this file except in compliance with the License.
|
|
841
|
-
* You may obtain a copy of the License at
|
|
842
|
-
*
|
|
843
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
844
|
-
*
|
|
845
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
846
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
847
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
848
|
-
* See the License for the specific language governing permissions and
|
|
849
|
-
* limitations under the License.
|
|
850
|
-
* =============================================================================
|
|
851
|
-
*/
|
|
852
|
-
function he(e, r, s, t = 0.5, n = Number.NEGATIVE_INFINITY, o = 0) {
|
|
853
|
-
const a = c(e, "boxes", "nonMaxSuppression"), i = c(r, "scores", "nonMaxSuppression"), l = C(a, i, s, t, n, o);
|
|
854
|
-
s = l.maxOutputSize, t = l.iouThreshold, n = l.scoreThreshold, o = l.softNmsSigma;
|
|
855
|
-
const u = { boxes: a, scores: i }, m = { maxOutputSize: s, iouThreshold: t, scoreThreshold: n, softNmsSigma: o }, b = h.runKernel(sn, u, m);
|
|
856
|
-
return { selectedIndices: b[0], selectedScores: b[1] };
|
|
857
|
-
}
|
|
858
|
-
const be = /* @__PURE__ */ f({ nonMaxSuppressionWithScore_: he });
|
|
859
|
-
/**
|
|
860
|
-
* @license
|
|
861
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
862
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
863
|
-
* you may not use this file except in compliance with the License.
|
|
864
|
-
* You may obtain a copy of the License at
|
|
865
|
-
*
|
|
866
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
867
|
-
*
|
|
868
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
869
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
870
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
871
|
-
* See the License for the specific language governing permissions and
|
|
872
|
-
* limitations under the License.
|
|
873
|
-
* =============================================================================
|
|
874
|
-
*/
|
|
875
|
-
async function ge(e, r, s, t = 0.5, n = Number.NEGATIVE_INFINITY, o = 0) {
|
|
876
|
-
const a = c(e, "boxes", "nonMaxSuppressionAsync"), i = c(r, "scores", "nonMaxSuppressionAsync"), l = C(a, i, s, t, n, o);
|
|
877
|
-
s = l.maxOutputSize, t = l.iouThreshold, n = l.scoreThreshold, o = l.softNmsSigma;
|
|
878
|
-
const u = await Promise.all([a.data(), i.data()]), m = u[0], b = u[1], { selectedIndices: _, selectedScores: $ } = ln(m, b, s, t, n, o);
|
|
879
|
-
return a !== e && a.dispose(), i !== r && i.dispose(), {
|
|
880
|
-
selectedIndices: w(_, "int32"),
|
|
881
|
-
selectedScores: w($)
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
const de = ge;
|
|
885
|
-
/**
|
|
886
|
-
* @license
|
|
887
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
888
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
889
|
-
* you may not use this file except in compliance with the License.
|
|
890
|
-
* You may obtain a copy of the License at
|
|
891
|
-
*
|
|
892
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
893
|
-
*
|
|
894
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
895
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
896
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
897
|
-
* See the License for the specific language governing permissions and
|
|
898
|
-
* limitations under the License.
|
|
899
|
-
* =============================================================================
|
|
900
|
-
*/
|
|
901
|
-
function $e(e, r, s, t = 0.5, n = Number.NEGATIVE_INFINITY, o = !1) {
|
|
902
|
-
const a = c(e, "boxes", "nonMaxSuppression"), i = c(r, "scores", "nonMaxSuppression"), l = C(
|
|
903
|
-
a,
|
|
904
|
-
i,
|
|
905
|
-
s,
|
|
906
|
-
t,
|
|
907
|
-
n,
|
|
908
|
-
null
|
|
909
|
-
/* softNmsSigma */
|
|
910
|
-
), u = l.maxOutputSize, m = l.iouThreshold, b = l.scoreThreshold, _ = { boxes: a, scores: i }, $ = {
|
|
911
|
-
maxOutputSize: u,
|
|
912
|
-
iouThreshold: m,
|
|
913
|
-
scoreThreshold: b,
|
|
914
|
-
padToMaxOutputSize: o
|
|
915
|
-
}, N = h.runKernel(nn, _, $);
|
|
916
|
-
return { selectedIndices: N[0], validOutputs: N[1] };
|
|
917
|
-
}
|
|
918
|
-
const Ee = /* @__PURE__ */ f({ nonMaxSuppressionPadded_: $e });
|
|
919
|
-
/**
|
|
920
|
-
* @license
|
|
921
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
922
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
923
|
-
* you may not use this file except in compliance with the License.
|
|
924
|
-
* You may obtain a copy of the License at
|
|
925
|
-
*
|
|
926
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
927
|
-
*
|
|
928
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
929
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
930
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
931
|
-
* See the License for the specific language governing permissions and
|
|
932
|
-
* limitations under the License.
|
|
933
|
-
* =============================================================================
|
|
934
|
-
*/
|
|
935
|
-
async function _e(e, r, s, t = 0.5, n = Number.NEGATIVE_INFINITY, o = !1) {
|
|
936
|
-
const a = c(e, "boxes", "nonMaxSuppressionAsync"), i = c(r, "scores", "nonMaxSuppressionAsync"), l = C(
|
|
937
|
-
a,
|
|
938
|
-
i,
|
|
939
|
-
s,
|
|
940
|
-
t,
|
|
941
|
-
n,
|
|
942
|
-
null
|
|
943
|
-
/* softNmsSigma */
|
|
944
|
-
), u = l.maxOutputSize, m = l.iouThreshold, b = l.scoreThreshold, [_, $] = await Promise.all([a.data(), i.data()]), { selectedIndices: N, validOutputs: A } = pn(_, $, u, m, b, o);
|
|
945
|
-
return a !== e && a.dispose(), i !== r && i.dispose(), {
|
|
946
|
-
selectedIndices: w(N, "int32"),
|
|
947
|
-
validOutputs: k(A, "int32")
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
const ke = _e;
|
|
951
|
-
/**
|
|
952
|
-
* @license
|
|
953
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
954
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
955
|
-
* you may not use this file except in compliance with the License.
|
|
956
|
-
* You may obtain a copy of the License at
|
|
957
|
-
*
|
|
958
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
959
|
-
*
|
|
960
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
961
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
962
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
963
|
-
* See the License for the specific language governing permissions and
|
|
964
|
-
* limitations under the License.
|
|
965
|
-
* =============================================================================
|
|
966
|
-
*/
|
|
967
|
-
function ye(e, r, s = !1, t = !1) {
|
|
968
|
-
const n = c(e, "images", "resizeBilinear");
|
|
969
|
-
p(n.rank === 3 || n.rank === 4, () => `Error in resizeBilinear: x must be rank 3 or 4, but got rank ${n.rank}.`), p(r.length === 2, () => `Error in resizeBilinear: new shape must 2D, but got shape ${r}.`), p(t === !1 || s === !1, () => "Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");
|
|
970
|
-
let o = n, a = !1;
|
|
971
|
-
n.rank === 3 && (a = !0, o = y(n, [1, n.shape[0], n.shape[1], n.shape[2]]));
|
|
972
|
-
const i = { images: o }, l = { alignCorners: s, halfPixelCenters: t, size: r }, u = h.runKernel(en, i, l);
|
|
973
|
-
return a ? y(u, [u.shape[1], u.shape[2], u.shape[3]]) : u;
|
|
974
|
-
}
|
|
975
|
-
const Ne = /* @__PURE__ */ f({ resizeBilinear_: ye });
|
|
976
|
-
/**
|
|
977
|
-
* @license
|
|
978
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
979
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
980
|
-
* you may not use this file except in compliance with the License.
|
|
981
|
-
* You may obtain a copy of the License at
|
|
982
|
-
*
|
|
983
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
984
|
-
*
|
|
985
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
986
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
987
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
988
|
-
* See the License for the specific language governing permissions and
|
|
989
|
-
* limitations under the License.
|
|
990
|
-
* =============================================================================
|
|
991
|
-
*/
|
|
992
|
-
function Ie(e, r, s = !1, t = !1) {
|
|
993
|
-
const n = c(e, "images", "resizeNearestNeighbor");
|
|
994
|
-
p(n.rank === 3 || n.rank === 4, () => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${n.rank}.`), p(r.length === 2, () => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${r}.`), p(n.dtype === "float32" || n.dtype === "int32", () => "`images` must have `int32` or `float32` as dtype"), p(t === !1 || s === !1, () => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");
|
|
995
|
-
let o = n, a = !1;
|
|
996
|
-
n.rank === 3 && (a = !0, o = y(n, [1, n.shape[0], n.shape[1], n.shape[2]]));
|
|
997
|
-
const i = { images: o }, l = { alignCorners: s, halfPixelCenters: t, size: r }, u = h.runKernel(tn, i, l);
|
|
998
|
-
return a ? y(u, [u.shape[1], u.shape[2], u.shape[3]]) : u;
|
|
999
|
-
}
|
|
1000
|
-
const Se = /* @__PURE__ */ f({ resizeNearestNeighbor_: Ie });
|
|
1001
|
-
/**
|
|
1002
|
-
* @license
|
|
1003
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
1004
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1005
|
-
* you may not use this file except in compliance with the License.
|
|
1006
|
-
* You may obtain a copy of the License at
|
|
1007
|
-
*
|
|
1008
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
1009
|
-
*
|
|
1010
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1011
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1012
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1013
|
-
* See the License for the specific language governing permissions and
|
|
1014
|
-
* limitations under the License.
|
|
1015
|
-
* =============================================================================
|
|
1016
|
-
*/
|
|
1017
|
-
function Te(e, r = "binary", s = !1, t = 0.5) {
|
|
1018
|
-
const n = c(e, "image", "threshold"), o = 0.2989, a = 0.587, i = 0.114, l = n.shape[0] * n.shape[1];
|
|
1019
|
-
let u = g(w([t]), 255), m, b, _, $;
|
|
1020
|
-
if (p(n.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${n.rank}.`), p(n.shape[2] === 3 || n.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${n.shape[2]}.`), p(n.dtype === "int32" || n.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${n.dtype}.`), p(r === "otsu" || r === "binary", () => `Method must be binary or otsu, but was ${r}`), n.shape[2] === 3) {
|
|
1021
|
-
[m, b, _] = ds(n, [1, 1, 1], -1);
|
|
1022
|
-
const T = g(m, o), B = g(b, a), R = g(_, i);
|
|
1023
|
-
$ = z(z(T, B), R);
|
|
1024
|
-
} else
|
|
1025
|
-
$ = e;
|
|
1026
|
-
if (r === "otsu") {
|
|
1027
|
-
const T = $n(q(Fn($), "int32"), fn([]), 256);
|
|
1028
|
-
u = xe(T, l);
|
|
1029
|
-
}
|
|
1030
|
-
const N = s ? ys($, u) : is($, u);
|
|
1031
|
-
return q(g(N, 255), "int32");
|
|
1032
|
-
}
|
|
1033
|
-
function xe(e, r) {
|
|
1034
|
-
let s = w([-1]), t = w([0]), n = w([0]), o, a, i, l, u, m;
|
|
1035
|
-
for (let b = 0; b < e.size - 1; b++) {
|
|
1036
|
-
o = x(e, 0, b + 1), a = x(e, b + 1), u = S(E(o), r), m = S(E(a), r);
|
|
1037
|
-
const _ = E(g(o, Z(0, o.size)));
|
|
1038
|
-
i = S(_, E(o));
|
|
1039
|
-
const $ = rn(a.shape, o.size), N = z(Z(0, a.size), $), A = g(a, N);
|
|
1040
|
-
l = S(E(A), E(a));
|
|
1041
|
-
const T = d(i, l), B = d(i, l), R = g(u, m);
|
|
1042
|
-
n = g(g(R, T), B);
|
|
1043
|
-
const Y = is(n, t);
|
|
1044
|
-
t = v(Y, n, t), s = v(Y, w([b]), s);
|
|
1045
|
-
}
|
|
1046
|
-
return s;
|
|
1047
|
-
}
|
|
1048
|
-
const Me = /* @__PURE__ */ f({ threshold_: Te });
|
|
1049
|
-
/**
|
|
1050
|
-
* @license
|
|
1051
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
1052
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1053
|
-
* you may not use this file except in compliance with the License.
|
|
1054
|
-
* You may obtain a copy of the License at
|
|
1055
|
-
*
|
|
1056
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1057
|
-
*
|
|
1058
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1059
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1060
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1061
|
-
* See the License for the specific language governing permissions and
|
|
1062
|
-
* limitations under the License.
|
|
1063
|
-
* =============================================================================
|
|
1064
|
-
*/
|
|
1065
|
-
function Ae(e, r, s = "nearest", t = "constant", n = 0, o) {
|
|
1066
|
-
const a = c(e, "image", "transform", "float32"), i = c(r, "transforms", "transform", "float32");
|
|
1067
|
-
p(a.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${a.rank}.`), p(i.rank === 2 && (i.shape[0] === a.shape[0] || i.shape[0] === 1) && i.shape[1] === 8, () => "Error in transform: Input transform should be batch x 8 or 1 x 8"), p(o == null || o.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${o}.`);
|
|
1068
|
-
const l = { image: a, transforms: i }, u = { interpolation: s, fillMode: t, fillValue: n, outputShape: o };
|
|
1069
|
-
return h.runKernel(on, l, u);
|
|
1070
|
-
}
|
|
1071
|
-
const we = /* @__PURE__ */ f({ transform_: Ae });
|
|
1072
|
-
/**
|
|
1073
|
-
* @license
|
|
1074
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1075
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1076
|
-
* you may not use this file except in compliance with the License.
|
|
1077
|
-
* You may obtain a copy of the License at
|
|
1078
|
-
*
|
|
1079
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1080
|
-
*
|
|
1081
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1082
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1083
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1084
|
-
* See the License for the specific language governing permissions and
|
|
1085
|
-
* limitations under the License.
|
|
1086
|
-
* =============================================================================
|
|
1087
|
-
*/
|
|
1088
|
-
function qe(e, r, s) {
|
|
1089
|
-
const t = c(e, "a", "bandPart");
|
|
1090
|
-
p(t.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${t.rank}.`);
|
|
1091
|
-
const n = t.shape, [o, a] = t.shape.slice(-2);
|
|
1092
|
-
let i, l;
|
|
1093
|
-
typeof r == "number" ? (p(r % 1 === 0, () => `bandPart(): numLower must be an integer, got ${r}.`), p(r <= o, () => `bandPart(): numLower (${r}) must not be greater than the number of rows (${o}).`), i = c(r < 0 ? o : r, "numLower", "bandPart")) : (p(r.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), i = v(ms(r, 0), o, as(r, o))), typeof s == "number" ? (p(s % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${s}.`), p(s <= a, () => `bandPart(): numUpper (${s}) must not be greater than the number of columns (${a}).`), l = c(s < 0 ? a : s, "numUpper", "bandPart")) : (p(s.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), l = v(ms(s, 0), a, as(s, a)));
|
|
1094
|
-
const u = y(Z(0, o, 1, "int32"), [-1, 1]), m = Z(0, a, 1, "int32"), b = d(u, m), _ = Rn(ys(b, i), An(b, V(l))), $ = hn([o, a], t.dtype);
|
|
1095
|
-
return y(H(Ns(y(t, [-1, o, a])).map((N) => v(_, N, $))), n);
|
|
1096
|
-
}
|
|
1097
|
-
const De = /* @__PURE__ */ f({ bandPart_: qe });
|
|
1098
|
-
/**
|
|
1099
|
-
* @license
|
|
1100
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1101
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1102
|
-
* you may not use this file except in compliance with the License.
|
|
1103
|
-
* You may obtain a copy of the License at
|
|
1104
|
-
*
|
|
1105
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1106
|
-
*
|
|
1107
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1108
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1109
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1110
|
-
* See the License for the specific language governing permissions and
|
|
1111
|
-
* limitations under the License.
|
|
1112
|
-
* =============================================================================
|
|
1113
|
-
*/
|
|
1114
|
-
function Be(e) {
|
|
1115
|
-
let r;
|
|
1116
|
-
if (Array.isArray(e)) {
|
|
1117
|
-
r = !1, p(e != null && e.length > 0, () => "Gram-Schmidt process: input must not be null, undefined, or empty");
|
|
1118
|
-
const n = e[0].shape[0];
|
|
1119
|
-
for (let o = 1; o < e.length; ++o)
|
|
1120
|
-
p(e[o].shape[0] === n, () => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[o].shape[0]} vs. ${n})`);
|
|
1121
|
-
} else
|
|
1122
|
-
r = !0, e = ds(e, e.shape[0], 0).map((n) => Xn(n, [0]));
|
|
1123
|
-
p(e.length <= e[0].shape[0], () => `Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`);
|
|
1124
|
-
const s = [], t = e;
|
|
1125
|
-
for (let n = 0; n < e.length; ++n)
|
|
1126
|
-
s.push(h.tidy(() => {
|
|
1127
|
-
let o = t[n];
|
|
1128
|
-
if (n > 0)
|
|
1129
|
-
for (let a = 0; a < n; ++a) {
|
|
1130
|
-
const i = g(E(g(s[a], o)), s[a]);
|
|
1131
|
-
o = d(o, i);
|
|
1132
|
-
}
|
|
1133
|
-
return S(o, ks(o, "euclidean"));
|
|
1134
|
-
}));
|
|
1135
|
-
return r ? H(s, 0) : s;
|
|
1136
|
-
}
|
|
1137
|
-
const Ge = /* @__PURE__ */ f({ gramSchmidt_: Be });
|
|
1138
|
-
/**
|
|
1139
|
-
* @license
|
|
1140
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1141
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1142
|
-
* you may not use this file except in compliance with the License.
|
|
1143
|
-
* You may obtain a copy of the License at
|
|
1144
|
-
*
|
|
1145
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1146
|
-
*
|
|
1147
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1148
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1149
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1150
|
-
* See the License for the specific language governing permissions and
|
|
1151
|
-
* limitations under the License.
|
|
1152
|
-
* =============================================================================
|
|
1153
|
-
*/
|
|
1154
|
-
function ze(e, r = !1) {
|
|
1155
|
-
if (p(e.rank >= 2, () => `qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`), e.rank === 2)
|
|
1156
|
-
return bs(e, r);
|
|
1157
|
-
{
|
|
1158
|
-
const s = e.shape.slice(0, e.shape.length - 2).reduce((l, u) => l * u), t = Ns(y(e, [
|
|
1159
|
-
s,
|
|
1160
|
-
e.shape[e.shape.length - 2],
|
|
1161
|
-
e.shape[e.shape.length - 1]
|
|
1162
|
-
]), 0), n = [], o = [];
|
|
1163
|
-
t.forEach((l) => {
|
|
1164
|
-
const [u, m] = bs(l, r);
|
|
1165
|
-
n.push(u), o.push(m);
|
|
1166
|
-
});
|
|
1167
|
-
const a = y(H(n, 0), e.shape), i = y(H(o, 0), e.shape);
|
|
1168
|
-
return [a, i];
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
function bs(e, r = !1) {
|
|
1172
|
-
return h.tidy(() => {
|
|
1173
|
-
p(e.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`);
|
|
1174
|
-
const s = e.shape[0], t = e.shape[1];
|
|
1175
|
-
let n = Tn(s), o = ss(e);
|
|
1176
|
-
const a = rs([[1]], [1, 1]);
|
|
1177
|
-
let i = ss(a);
|
|
1178
|
-
const l = s >= t ? t : s;
|
|
1179
|
-
for (let u = 0; u < l; ++u) {
|
|
1180
|
-
const m = o, b = i, _ = n;
|
|
1181
|
-
[i, o, n] = h.tidy(() => {
|
|
1182
|
-
const $ = x(o, [u, u], [s - u, 1]), N = ks($), A = x(o, [u, u], [1, 1]), T = v(is(A, 0), rs([[-1]]), rs([[1]])), B = d(A, g(T, N)), R = S($, B);
|
|
1183
|
-
R.shape[0] === 1 ? i = ss(a) : i = ts([
|
|
1184
|
-
a,
|
|
1185
|
-
x(R, [1, 0], [R.shape[0] - 1, R.shape[1]])
|
|
1186
|
-
], 0);
|
|
1187
|
-
const Y = V(S(G(T, B), N)), j = x(o, [u, 0], [s - u, t]), X = g(Y, i), cs = hs(i);
|
|
1188
|
-
if (u === 0)
|
|
1189
|
-
o = d(j, G(X, G(cs, j)));
|
|
1190
|
-
else {
|
|
1191
|
-
const J = d(j, G(X, G(cs, j)));
|
|
1192
|
-
o = ts([x(o, [0, 0], [u, t]), J], 0);
|
|
1193
|
-
}
|
|
1194
|
-
const us = hs(X), F = x(n, [0, u], [s, n.shape[1] - u]);
|
|
1195
|
-
if (u === 0)
|
|
1196
|
-
n = d(F, G(G(F, i), us));
|
|
1197
|
-
else {
|
|
1198
|
-
const J = d(F, G(G(F, i), us));
|
|
1199
|
-
n = ts([x(n, [0, 0], [s, u]), J], 1);
|
|
1200
|
-
}
|
|
1201
|
-
return [i, o, n];
|
|
1202
|
-
}), an([m, b, _]);
|
|
1203
|
-
}
|
|
1204
|
-
return !r && s > t && (n = x(n, [0, 0], [s, t]), o = x(o, [0, 0], [t, t])), [n, o];
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
const Oe = /* @__PURE__ */ f({ qr_: ze });
|
|
1208
|
-
/**
|
|
1209
|
-
* @license
|
|
1210
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1211
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1212
|
-
* you may not use this file except in compliance with the License.
|
|
1213
|
-
* You may obtain a copy of the License at
|
|
1214
|
-
*
|
|
1215
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1216
|
-
*
|
|
1217
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1218
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1219
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1220
|
-
* See the License for the specific language governing permissions and
|
|
1221
|
-
* limitations under the License.
|
|
1222
|
-
* =============================================================================
|
|
1223
|
-
*/
|
|
1224
|
-
var I;
|
|
1225
|
-
(function(e) {
|
|
1226
|
-
e[e.NONE = 0] = "NONE", e[e.MEAN = 1] = "MEAN", e[e.SUM = 2] = "SUM", e[e.SUM_BY_NONZERO_WEIGHTS = 3] = "SUM_BY_NONZERO_WEIGHTS";
|
|
1227
|
-
})(I || (I = {}));
|
|
1228
|
-
function Le(e, r, s = I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1229
|
-
const t = c(e, "losses", "computeWeightedLoss");
|
|
1230
|
-
let n = null;
|
|
1231
|
-
r != null && (n = c(r, "weights", "computeWeightedLoss"));
|
|
1232
|
-
const o = n == null ? t : g(t, n);
|
|
1233
|
-
if (s === I.NONE)
|
|
1234
|
-
return o;
|
|
1235
|
-
if (s === I.SUM)
|
|
1236
|
-
return E(o);
|
|
1237
|
-
if (s === I.MEAN) {
|
|
1238
|
-
if (n == null)
|
|
1239
|
-
return Kn(o);
|
|
1240
|
-
{
|
|
1241
|
-
const a = t.size / n.size, i = S(E(o), E(n));
|
|
1242
|
-
return a > 1 ? S(i, k(a)) : i;
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
if (s === I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1246
|
-
if (n == null)
|
|
1247
|
-
return S(E(o), k(t.size));
|
|
1248
|
-
{
|
|
1249
|
-
const a = g(n, gn(t.shape)), i = q(E(Cn(a, k(0))), "float32");
|
|
1250
|
-
return S(E(o), i);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
throw Error(`Unknown reduction: ${s}`);
|
|
1254
|
-
}
|
|
1255
|
-
const L = /* @__PURE__ */ f({ computeWeightedLoss_: Le });
|
|
1256
|
-
/**
|
|
1257
|
-
* @license
|
|
1258
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1259
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1260
|
-
* you may not use this file except in compliance with the License.
|
|
1261
|
-
* You may obtain a copy of the License at
|
|
1262
|
-
*
|
|
1263
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1264
|
-
*
|
|
1265
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1266
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1267
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1268
|
-
* See the License for the specific language governing permissions and
|
|
1269
|
-
* limitations under the License.
|
|
1270
|
-
* =============================================================================
|
|
1271
|
-
*/
|
|
1272
|
-
function Re(e, r, s, t = I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1273
|
-
const n = c(e, "labels", "absoluteDifference"), o = c(r, "predictions", "absoluteDifference");
|
|
1274
|
-
let a = null;
|
|
1275
|
-
s != null && (a = c(s, "weights", "absoluteDifference")), O(n.shape, o.shape, "Error in absoluteDifference: ");
|
|
1276
|
-
const i = M(d(n, o));
|
|
1277
|
-
return L(i, a, t);
|
|
1278
|
-
}
|
|
1279
|
-
const We = /* @__PURE__ */ f({ absoluteDifference_: Re });
|
|
1280
|
-
function Ke(e, r, s, t, n = I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1281
|
-
const o = c(e, "labels", "cosineDistance"), a = c(r, "predictions", "cosineDistance");
|
|
1282
|
-
let i = null;
|
|
1283
|
-
t != null && (i = c(t, "weights", "cosineDistance")), O(o.shape, a.shape, "Error in cosineDistance: ");
|
|
1284
|
-
const l = k(1), u = d(l, E(g(o, a), s, !0));
|
|
1285
|
-
return L(u, i, n);
|
|
1286
|
-
}
|
|
1287
|
-
const ve = /* @__PURE__ */ f({ cosineDistance_: Ke });
|
|
1288
|
-
function Ve(e, r, s, t = I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1289
|
-
let n = c(e, "labels", "hingeLoss");
|
|
1290
|
-
const o = c(r, "predictions", "hingeLoss");
|
|
1291
|
-
let a = null;
|
|
1292
|
-
s != null && (a = c(s, "weights", "hingeLoss")), O(n.shape, o.shape, "Error in hingeLoss: ");
|
|
1293
|
-
const i = k(1);
|
|
1294
|
-
n = d(g(k(2), n), i);
|
|
1295
|
-
const l = Es(d(i, g(n, o)));
|
|
1296
|
-
return L(l, a, t);
|
|
1297
|
-
}
|
|
1298
|
-
const Ce = /* @__PURE__ */ f({ hingeLoss_: Ve });
|
|
1299
|
-
/**
|
|
1300
|
-
* @license
|
|
1301
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1302
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1303
|
-
* you may not use this file except in compliance with the License.
|
|
1304
|
-
* You may obtain a copy of the License at
|
|
1305
|
-
*
|
|
1306
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1307
|
-
*
|
|
1308
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1309
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1310
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1311
|
-
* See the License for the specific language governing permissions and
|
|
1312
|
-
* limitations under the License.
|
|
1313
|
-
* =============================================================================
|
|
1314
|
-
*/
|
|
1315
|
-
function Pe(e, r, s, t = 1, n = I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1316
|
-
const o = c(e, "labels", "huberLoss"), a = c(r, "predictions", "huberLoss");
|
|
1317
|
-
let i = null;
|
|
1318
|
-
s != null && (i = c(s, "weights", "huberLoss")), O(o.shape, a.shape, "Error in huberLoss: ");
|
|
1319
|
-
const l = k(t), u = M(d(a, o)), m = as(u, l), b = d(u, m), _ = z(g(k(0.5), gs(m)), g(l, b));
|
|
1320
|
-
return L(_, i, n);
|
|
1321
|
-
}
|
|
1322
|
-
const Ye = /* @__PURE__ */ f({ huberLoss_: Pe });
|
|
1323
|
-
/**
|
|
1324
|
-
* @license
|
|
1325
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1326
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1327
|
-
* you may not use this file except in compliance with the License.
|
|
1328
|
-
* You may obtain a copy of the License at
|
|
1329
|
-
*
|
|
1330
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1331
|
-
*
|
|
1332
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1333
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1334
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1335
|
-
* See the License for the specific language governing permissions and
|
|
1336
|
-
* limitations under the License.
|
|
1337
|
-
* =============================================================================
|
|
1338
|
-
*/
|
|
1339
|
-
function je(e, r, s, t = 1e-7, n = I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1340
|
-
const o = c(e, "labels", "logLoss"), a = c(r, "predictions", "logLoss");
|
|
1341
|
-
let i = null;
|
|
1342
|
-
s != null && (i = c(s, "weights", "logLoss")), O(o.shape, a.shape, "Error in logLoss: ");
|
|
1343
|
-
const l = k(1), u = k(t), m = V(g(o, ps(z(a, u)))), b = g(d(l, o), ps(z(d(l, a), u))), _ = d(m, b);
|
|
1344
|
-
return L(_, i, n);
|
|
1345
|
-
}
|
|
1346
|
-
const Fe = /* @__PURE__ */ f({ logLoss_: je });
|
|
1347
|
-
/**
|
|
1348
|
-
* @license
|
|
1349
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1350
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1351
|
-
* you may not use this file except in compliance with the License.
|
|
1352
|
-
* You may obtain a copy of the License at
|
|
1353
|
-
*
|
|
1354
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1355
|
-
*
|
|
1356
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1357
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1358
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1359
|
-
* See the License for the specific language governing permissions and
|
|
1360
|
-
* limitations under the License.
|
|
1361
|
-
* =============================================================================
|
|
1362
|
-
*/
|
|
1363
|
-
function Ue(e, r, s, t = I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1364
|
-
const n = c(e, "labels", "meanSquaredError"), o = c(r, "predictions", "meanSquaredError");
|
|
1365
|
-
let a = null;
|
|
1366
|
-
s != null && (a = c(s, "weights", "meanSquaredError")), O(n.shape, o.shape, "Error in meanSquaredError: ");
|
|
1367
|
-
const i = Zn(n, o);
|
|
1368
|
-
return L(i, a, t);
|
|
1369
|
-
}
|
|
1370
|
-
const Ze = /* @__PURE__ */ f({ meanSquaredError_: Ue });
|
|
1371
|
-
/**
|
|
1372
|
-
* @license
|
|
1373
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1374
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1375
|
-
* you may not use this file except in compliance with the License.
|
|
1376
|
-
* You may obtain a copy of the License at
|
|
1377
|
-
*
|
|
1378
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1379
|
-
*
|
|
1380
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1381
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1382
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1383
|
-
* See the License for the specific language governing permissions and
|
|
1384
|
-
* limitations under the License.
|
|
1385
|
-
* =============================================================================
|
|
1386
|
-
*/
|
|
1387
|
-
function He(e, r) {
|
|
1388
|
-
const s = c(e, "labels", "sigmoidCrossEntropyWithLogits"), t = c(r, "logits", "sigmoidCrossEntropyWithLogits");
|
|
1389
|
-
O(s.shape, t.shape, "Error in sigmoidCrossEntropyWithLogits: ");
|
|
1390
|
-
const n = Es(t), o = g(t, s), a = zn(os(V(M(t))));
|
|
1391
|
-
return z(d(n, o), a);
|
|
1392
|
-
}
|
|
1393
|
-
function Xe(e, r, s, t = 0, n = I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1394
|
-
let o = c(e, "multiClassLabels", "sigmoidCrossEntropy");
|
|
1395
|
-
const a = c(r, "logits", "sigmoidCrossEntropy");
|
|
1396
|
-
let i = null;
|
|
1397
|
-
if (s != null && (i = c(s, "weights", "sigmoidCrossEntropy")), O(o.shape, a.shape, "Error in sigmoidCrossEntropy: "), t > 0) {
|
|
1398
|
-
const u = k(t), m = k(1), b = k(0.5);
|
|
1399
|
-
o = z(g(o, d(m, u)), g(b, u));
|
|
1400
|
-
}
|
|
1401
|
-
const l = He(o, a);
|
|
1402
|
-
return L(l, i, n);
|
|
1403
|
-
}
|
|
1404
|
-
const Je = /* @__PURE__ */ f({ sigmoidCrossEntropy_: Xe });
|
|
1405
|
-
/**
|
|
1406
|
-
* @license
|
|
1407
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1408
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1409
|
-
* you may not use this file except in compliance with the License.
|
|
1410
|
-
* You may obtain a copy of the License at
|
|
1411
|
-
*
|
|
1412
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1413
|
-
*
|
|
1414
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1415
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1416
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1417
|
-
* See the License for the specific language governing permissions and
|
|
1418
|
-
* limitations under the License.
|
|
1419
|
-
* =============================================================================
|
|
1420
|
-
*/
|
|
1421
|
-
function Qe(e, r, s = -1) {
|
|
1422
|
-
if (s === -1 && (s = r.rank - 1), s !== r.rank - 1)
|
|
1423
|
-
throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${r.rank} and dim was ${s}`);
|
|
1424
|
-
return cn((n, o, a) => {
|
|
1425
|
-
const l = bn(o, [s], !0), u = d(q(o, "float32"), l);
|
|
1426
|
-
a([n, u]);
|
|
1427
|
-
const m = V(g(u, n));
|
|
1428
|
-
return { value: E(m, [s]), gradFunc: ($, N) => {
|
|
1429
|
-
const [A, T] = N, B = $s($.shape, [s]);
|
|
1430
|
-
return [
|
|
1431
|
-
g(y($, B), d(q(A, "float32"), os(T))),
|
|
1432
|
-
g(y($, B), d(os(T), q(A, "float32")))
|
|
1433
|
-
];
|
|
1434
|
-
} };
|
|
1435
|
-
})(e, r);
|
|
1436
|
-
}
|
|
1437
|
-
function st(e, r, s, t = 0, n = I.SUM_BY_NONZERO_WEIGHTS) {
|
|
1438
|
-
let o = c(e, "onehotLabels", "softmaxCrossEntropy");
|
|
1439
|
-
const a = c(r, "logits", "softmaxCrossEntropy");
|
|
1440
|
-
let i = null;
|
|
1441
|
-
if (s != null && (i = c(s, "weights", "softmaxCrossEntropy")), O(o.shape, a.shape, "Error in softmaxCrossEntropy: "), t > 0) {
|
|
1442
|
-
const u = k(t), m = k(1), b = k(o.shape[1]);
|
|
1443
|
-
o = z(g(o, d(m, u)), S(u, b));
|
|
1444
|
-
}
|
|
1445
|
-
const l = Qe(o, a);
|
|
1446
|
-
return L(l, i, n);
|
|
1447
|
-
}
|
|
1448
|
-
const nt = /* @__PURE__ */ f({ softmaxCrossEntropy_: st });
|
|
1449
|
-
/**
|
|
1450
|
-
* @license
|
|
1451
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1452
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1453
|
-
* you may not use this file except in compliance with the License.
|
|
1454
|
-
* You may obtain a copy of the License at
|
|
1455
|
-
*
|
|
1456
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1457
|
-
*
|
|
1458
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1459
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1460
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1461
|
-
* See the License for the specific language governing permissions and
|
|
1462
|
-
* limitations under the License.
|
|
1463
|
-
* =============================================================================
|
|
1464
|
-
*/
|
|
1465
|
-
const kt = {
|
|
1466
|
-
flipLeftRight: te,
|
|
1467
|
-
grayscaleToRGB: oe,
|
|
1468
|
-
resizeNearestNeighbor: Se,
|
|
1469
|
-
resizeBilinear: Ne,
|
|
1470
|
-
rgbToGrayscale: ie,
|
|
1471
|
-
rotateWithOffset: ue,
|
|
1472
|
-
cropAndResize: ne,
|
|
1473
|
-
nonMaxSuppression: pe,
|
|
1474
|
-
nonMaxSuppressionAsync: me,
|
|
1475
|
-
nonMaxSuppressionWithScore: be,
|
|
1476
|
-
nonMaxSuppressionWithScoreAsync: de,
|
|
1477
|
-
nonMaxSuppressionPadded: Ee,
|
|
1478
|
-
nonMaxSuppressionPaddedAsync: ke,
|
|
1479
|
-
threshold: Me,
|
|
1480
|
-
transform: we
|
|
1481
|
-
}, yt = {
|
|
1482
|
-
bandPart: De,
|
|
1483
|
-
gramSchmidt: Ge,
|
|
1484
|
-
qr: Oe
|
|
1485
|
-
}, Nt = {
|
|
1486
|
-
absoluteDifference: We,
|
|
1487
|
-
computeWeightedLoss: L,
|
|
1488
|
-
cosineDistance: ve,
|
|
1489
|
-
hingeLoss: Ce,
|
|
1490
|
-
huberLoss: Ye,
|
|
1491
|
-
logLoss: Fe,
|
|
1492
|
-
meanSquaredError: Ze,
|
|
1493
|
-
sigmoidCrossEntropy: Je,
|
|
1494
|
-
softmaxCrossEntropy: nt
|
|
1495
|
-
};
|
|
1496
|
-
export {
|
|
1497
|
-
Fn as A,
|
|
1498
|
-
Zn as B,
|
|
1499
|
-
Nt as a,
|
|
1500
|
-
Rn as b,
|
|
1501
|
-
ys as c,
|
|
1502
|
-
U as d,
|
|
1503
|
-
is as e,
|
|
1504
|
-
ms as f,
|
|
1505
|
-
An as g,
|
|
1506
|
-
W as h,
|
|
1507
|
-
Tn as i,
|
|
1508
|
-
zn as j,
|
|
1509
|
-
as as k,
|
|
1510
|
-
yt as l,
|
|
1511
|
-
Kn as m,
|
|
1512
|
-
V as n,
|
|
1513
|
-
kt as o,
|
|
1514
|
-
Cn as p,
|
|
1515
|
-
fs as q,
|
|
1516
|
-
ks as r,
|
|
1517
|
-
Xn as s,
|
|
1518
|
-
hs as t,
|
|
1519
|
-
Ns as u,
|
|
1520
|
-
Yn as v,
|
|
1521
|
-
v as w,
|
|
1522
|
-
qn as x,
|
|
1523
|
-
Ne as y,
|
|
1524
|
-
Se as z
|
|
1525
|
-
};
|