@genai-fi/nanogpt 0.9.1 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +352 -14
- package/dist/Generator.js +69 -78
- package/dist/{RealDiv-D4EzDsC0.js → RealDiv-DgA3z9oO.js} +32 -206
- package/dist/Reshape-CF6odzV4.js +16 -0
- package/dist/Reshape-_kILl6tK.js +81 -0
- package/dist/TeachableLLM.js +28 -22
- package/dist/Trainer.d.ts +2 -0
- package/dist/Trainer.js +3 -2
- package/dist/{axis_util-TbGYJ208.js → axis_util-BvHEw88j.js} +7 -23
- package/dist/backend.d.ts +2 -1
- package/dist/backend.js +10 -4
- package/dist/backend_util-D-rUb2ty.js +474 -0
- package/dist/backend_webgpu-B0u2ndUn.js +547 -0
- package/dist/binary_op_util-pKXltfxI.js +192 -0
- package/dist/broadcast_to-CwF7XIeu.js +30 -0
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +3 -3
- package/dist/checks/check.d.ts +1 -1
- package/dist/checks/check.js +8 -8
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/index.d.ts +2 -0
- package/dist/checks/index.js +7 -5
- package/dist/checks/matMulGelu.js +6 -6
- package/dist/checks/normRMS.js +7 -7
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/packUnpack.d.ts +1 -0
- package/dist/checks/packUnpack.js +18 -0
- package/dist/checks/qkv.js +12 -27
- package/dist/checks/rope.js +2 -2
- package/dist/checks/weights.js +18 -16
- package/dist/complex-CSlYz-2T.js +13 -0
- package/dist/complex_util-Yc1A_gV1.js +55 -0
- package/dist/concat-BHlIJeyT.js +19 -0
- package/dist/concat_util-DcJk7YHS.js +22 -0
- package/dist/data/docx.js +1 -1
- package/dist/data/parquet.js +2 -2
- package/dist/data/pdf.js +1 -1
- package/dist/data/textLoader.js +1 -1
- package/dist/{dataset-DlZtKmBq.js → dataset-0xP8GjwI.js} +136 -236
- package/dist/dropout-C1pM3f11.js +99 -0
- package/dist/expand_dims-BPG4fwBP.js +13 -0
- package/dist/exports_initializers-xuidcwI4.js +7 -0
- package/dist/gather-DykLGqmW.js +10 -0
- package/dist/{gelu-Bp_-935b.js → gelu-CNLFZWea.js} +11 -10
- package/dist/{gpgpu_math-CDaYiyE_.js → gpgpu_math-DDVJCn6-.js} +90 -265
- package/dist/{index-C4L8Cm77.js → index-CieiGp4Y.js} +14 -14
- package/dist/index-CjOj7j-u.js +7308 -0
- package/dist/{index-Tf7vU29b.js → index-Cp39cXWe.js} +3 -10
- package/dist/{index-Dwqa6Zy2.js → index-DvYrXKkX.js} +2 -2
- package/dist/index-ZyQhjEPo.js +2157 -0
- package/dist/{jszip.min-CjP2V1VV.js → jszip.min-Bz5-11Bk.js} +56 -57
- package/dist/kernel_funcs_utils-Dg_-E44D.js +308 -0
- package/dist/layers/BaseLayer.d.ts +1 -0
- package/dist/layers/BaseLayer.js +7 -6
- package/dist/layers/CausalSelfAttention.d.ts +0 -1
- package/dist/layers/CausalSelfAttention.js +56 -55
- package/dist/layers/MLP.js +15 -16
- package/dist/layers/PositionEmbedding.js +5 -14
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.d.ts +2 -0
- package/dist/layers/RoPECache.js +22 -17
- package/dist/layers/TiedEmbedding.js +22 -17
- package/dist/layers/TransformerBlock.js +21 -20
- package/dist/loader/load.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +39 -33
- package/dist/loader/save.js +1 -1
- package/dist/log_sum_exp-DWI-76TI.js +41 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.js +63 -52
- package/dist/matMul16--R5hOwDG.js +77 -0
- package/dist/mat_mul-DeAh4uTH.js +12 -0
- package/dist/mod-Gt1rMB4n.js +12 -0
- package/dist/models/NanoGPTV1.js +40 -31
- package/dist/models/model.d.ts +2 -0
- package/dist/models/model.js +37 -29
- package/dist/{mulmat_packed_gpu-BT60jmzP.js → mulmat_packed_gpu-BMFhLwta.js} +1 -17
- package/dist/{non_max_suppression_impl-CsEgBuMA.js → non_max_suppression_impl-B2W7YjZB.js} +0 -32
- package/dist/ones-CAMiP4I2.js +15 -0
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.d.ts +1 -1
- package/dist/ops/adamMoments.js +4 -4
- package/dist/ops/add16.d.ts +2 -0
- package/dist/ops/add16.js +9 -0
- package/dist/ops/appendCache.js +16 -9
- package/dist/ops/attentionMask.js +4 -4
- package/dist/ops/concat16.d.ts +2 -0
- package/dist/ops/concat16.js +9 -0
- package/dist/ops/cpu/adamAdjust.js +14 -13
- package/dist/ops/cpu/adamMoments.js +10 -9
- package/dist/ops/cpu/appendCache.js +9 -8
- package/dist/ops/cpu/attentionMask.js +15 -14
- package/dist/ops/cpu/fusedSoftmax.js +13 -12
- package/dist/ops/cpu/gatherSub.js +9 -24
- package/dist/ops/cpu/gelu.js +13 -12
- package/dist/ops/cpu/matMul16.d.ts +1 -0
- package/dist/ops/cpu/matMul16.js +16 -0
- package/dist/ops/cpu/matMulGelu.js +18 -16
- package/dist/ops/cpu/matMulMul.js +8 -7
- package/dist/ops/cpu/mulDropout.js +4 -3
- package/dist/ops/cpu/normRMS.js +11 -10
- package/dist/ops/cpu/qkv.js +17 -13
- package/dist/ops/cpu/rope.js +23 -22
- package/dist/ops/cpu/scatterSub.js +16 -30
- package/dist/ops/dot16.d.ts +2 -0
- package/dist/ops/dot16.js +42 -0
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/add16.d.ts +1 -0
- package/dist/ops/grads/add16.js +27 -0
- package/dist/ops/grads/attentionMask.js +12 -19
- package/dist/ops/grads/gelu.js +4 -3
- package/dist/ops/grads/matMul16.d.ts +2 -0
- package/dist/ops/grads/matMul16.js +9 -0
- package/dist/ops/grads/matMulGelu.js +8 -7
- package/dist/ops/grads/normRMS.js +8 -7
- package/dist/ops/grads/{fusedSoftmax.d.ts → pack16.d.ts} +1 -1
- package/dist/ops/grads/pack16.js +7 -0
- package/dist/ops/grads/qkv.d.ts +3 -1
- package/dist/ops/grads/qkv.js +28 -22
- package/dist/ops/grads/rope.d.ts +2 -1
- package/dist/ops/grads/rope.js +6 -13
- package/dist/ops/grads/softmax16.d.ts +2 -0
- package/dist/ops/grads/softmax16.js +26 -0
- package/dist/ops/grads/unpack16.d.ts +2 -0
- package/dist/ops/grads/unpack16.js +6 -0
- package/dist/ops/grads/utils.d.ts +3 -0
- package/dist/ops/grads/utils.js +10 -0
- package/dist/ops/matMul16.d.ts +15 -0
- package/dist/ops/matMul16.js +13 -0
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mul16.d.ts +2 -0
- package/dist/ops/mul16.js +8 -0
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/pack16.d.ts +2 -0
- package/dist/ops/pack16.js +6 -0
- package/dist/ops/qkv.d.ts +1 -1
- package/dist/ops/qkv.js +8 -4
- package/dist/ops/reshape16.d.ts +2 -0
- package/dist/ops/reshape16.js +43 -0
- package/dist/ops/rope.d.ts +1 -1
- package/dist/ops/rope.js +8 -10
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/slice16.d.ts +2 -0
- package/dist/ops/slice16.js +9 -0
- package/dist/ops/softmax16.d.ts +2 -0
- package/dist/ops/softmax16.js +12 -0
- package/dist/ops/sub16.d.ts +2 -0
- package/dist/ops/sub16.js +8 -0
- package/dist/ops/sum16.d.ts +2 -0
- package/dist/ops/sum16.js +13 -0
- package/dist/ops/transpose16.d.ts +3 -0
- package/dist/ops/transpose16.js +41 -0
- package/dist/ops/unpack16.d.ts +2 -0
- package/dist/ops/unpack16.js +6 -0
- package/dist/ops/webgl/adamAdjust.js +3 -2
- package/dist/ops/webgl/adamMoments.js +2 -1
- package/dist/ops/webgl/appendCache.js +2 -1
- package/dist/ops/webgl/attentionMask.js +5 -4
- package/dist/ops/webgl/fusedSoftmax.js +6 -4
- package/dist/ops/webgl/gatherSub.js +7 -6
- package/dist/ops/webgl/gelu.js +3 -2
- package/dist/ops/webgl/log.js +12 -27
- package/dist/ops/webgl/matMul16.d.ts +1 -0
- package/dist/ops/webgl/matMul16.js +37 -0
- package/dist/ops/webgl/matMulGelu.js +17 -15
- package/dist/ops/webgl/matMulMul.js +13 -12
- package/dist/ops/webgl/mulDropout.js +9 -8
- package/dist/ops/webgl/normRMS.js +8 -7
- package/dist/ops/webgl/qkv.js +6 -5
- package/dist/ops/webgl/rope.js +11 -10
- package/dist/ops/webgl/scatterSub.js +6 -5
- package/dist/ops/webgpu/adamAdjust.js +12 -10
- package/dist/ops/webgpu/adamMoments.js +27 -22
- package/dist/ops/webgpu/add16.d.ts +1 -0
- package/dist/ops/webgpu/add16.js +14 -0
- package/dist/ops/webgpu/appendCache.js +64 -17
- package/dist/ops/webgpu/attentionMask.js +19 -62
- package/dist/ops/webgpu/attentionMask32_program.d.ts +19 -0
- package/dist/ops/webgpu/attentionMask32_program.js +54 -0
- package/dist/ops/webgpu/concat16.d.ts +19 -0
- package/dist/ops/webgpu/concat16.js +128 -0
- package/dist/ops/webgpu/gatherSub.js +9 -7
- package/dist/ops/webgpu/gelu.js +78 -31
- package/dist/ops/webgpu/index.js +12 -0
- package/dist/ops/webgpu/matMul16.d.ts +1 -0
- package/dist/ops/webgpu/matMul16.js +58 -0
- package/dist/ops/webgpu/matMul16_program.d.ts +42 -0
- package/dist/ops/webgpu/matMul16_program.js +336 -0
- package/dist/ops/webgpu/mul16.d.ts +1 -0
- package/dist/ops/webgpu/mul16.js +14 -0
- package/dist/ops/webgpu/normRMS.js +21 -40
- package/dist/ops/webgpu/normRMS16_program.d.ts +9 -0
- package/dist/ops/webgpu/normRMS16_program.js +24 -0
- package/dist/ops/webgpu/normRMS32_program.d.ts +9 -0
- package/dist/ops/webgpu/normRMS32_program.js +24 -0
- package/dist/ops/webgpu/normRMSGrad.js +113 -64
- package/dist/ops/webgpu/pack16.d.ts +1 -0
- package/dist/ops/webgpu/pack16.js +19 -0
- package/dist/ops/webgpu/pack16_program.d.ts +19 -0
- package/dist/ops/webgpu/pack16_program.js +92 -0
- package/dist/ops/webgpu/qkv.js +20 -55
- package/dist/ops/webgpu/rope.js +77 -22
- package/dist/ops/webgpu/scatterSub.js +9 -7
- package/dist/ops/webgpu/slice16.d.ts +7 -0
- package/dist/ops/webgpu/slice16.js +71 -0
- package/dist/{variable-Bm2OFwGI.js → ops/webgpu/softmax16.d.ts} +2 -8
- package/dist/ops/webgpu/softmax16.js +23 -0
- package/dist/ops/webgpu/softmax16_program.d.ts +13 -0
- package/dist/ops/webgpu/softmax16_program.js +73 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.d.ts +17 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.js +75 -0
- package/dist/ops/webgpu/softmax16grad.d.ts +1 -0
- package/dist/ops/webgpu/softmax16grad.js +38 -0
- package/dist/ops/webgpu/sub16.d.ts +1 -0
- package/dist/ops/webgpu/sub16.js +14 -0
- package/dist/ops/webgpu/sum16.d.ts +1 -0
- package/dist/ops/webgpu/sum16.js +40 -0
- package/dist/ops/webgpu/transpose16.d.ts +1 -0
- package/dist/ops/webgpu/transpose16.js +35 -0
- package/dist/ops/webgpu/transpose16_program.d.ts +16 -0
- package/dist/ops/webgpu/transpose16_program.js +50 -0
- package/dist/ops/webgpu/transpose16_shared_program.d.ts +15 -0
- package/dist/ops/webgpu/transpose16_shared_program.js +71 -0
- package/dist/ops/webgpu/unpack16.d.ts +1 -0
- package/dist/ops/webgpu/unpack16.js +49 -0
- package/dist/ops/webgpu/utils/binary_op.d.ts +19 -0
- package/dist/ops/webgpu/utils/binary_op.js +79 -0
- package/dist/ops/webgpu/utils/deviceInfo.d.ts +7 -0
- package/dist/ops/webgpu/utils/deviceInfo.js +11 -0
- package/dist/ops/webgpu/utils/reductions.d.ts +32 -4
- package/dist/ops/webgpu/utils/reductions.js +236 -45
- package/dist/ops-CNI3TwqM.js +645 -0
- package/dist/pack16-CFUqumar.js +41 -0
- package/dist/{papaparse.min-C8l2Kvo1.js → papaparse.min-C0cScC2i.js} +2 -8
- package/dist/{parquet-C0Tlmv9c.js → parquet-BE8MU_ge.js} +201 -278
- package/dist/patches/PackedTensor.d.ts +12 -0
- package/dist/patches/PackedTensor.js +11 -0
- package/dist/patches/engine.d.ts +261 -0
- package/dist/patches/engine.js +10 -0
- package/dist/patches/tape.d.ts +12 -0
- package/dist/patches/tape.js +5 -0
- package/dist/patches/webgpu_backend.d.ts +18 -0
- package/dist/patches/webgpu_backend.js +57 -0
- package/dist/{tensor-CZr4dh61.js → patches/webgpu_base.d.ts} +5 -8
- package/dist/patches/webgpu_base.js +34 -0
- package/dist/patches/webgpu_program.d.ts +36 -0
- package/dist/patches/webgpu_program.js +401 -0
- package/dist/{pdf-kJD-f258.js → pdf-NIhmP3sq.js} +424 -428
- package/dist/random_width-DY6Kk2Dl.js +10051 -0
- package/dist/range-BMS52eQi.js +11 -0
- package/dist/reciprocal-CTmshQ9J.js +10 -0
- package/dist/{register_all_kernels-DIGpEwcf.js → register_all_kernels-Bwu1PTuU.js} +719 -9766
- package/dist/relu-yZ2-7WxU.js +10 -0
- package/dist/reshape-DevtBWtf.js +10 -0
- package/dist/rope-B5UUMsPi.js +32 -0
- package/dist/{scatter_nd_util-BQdz--Gn.js → scatter_nd_util-5EL-8VAQ.js} +1 -1
- package/dist/selu_util-D1w6yyTO.js +303 -0
- package/dist/{shared-DuP7ue-R.js → shared-BRksrJb3.js} +1 -17
- package/dist/shared-BuAXb4CI.js +2145 -0
- package/dist/sin-BGfy2HZo.js +16 -0
- package/dist/slice-D_gkkqZK.js +13 -0
- package/dist/slice_util-DtEldBfK.js +261 -0
- package/dist/softmax-ZHVebtR1.js +13 -0
- package/dist/split-DrfihRpZ.js +10 -0
- package/dist/squeeze-DZEpeblb.js +11 -0
- package/dist/stack-yOIAalTq.js +13 -0
- package/dist/sum-_fzj5ZTB.js +12 -0
- package/dist/tensor-DdQUJZlz.js +909 -0
- package/dist/tensor-f35l8Odg.js +8 -0
- package/dist/tensor1d-CeZuc-Rv.js +12 -0
- package/dist/tensor2d-G4Ys2GxX.js +15 -0
- package/dist/tensor4d-B8roDgtc.js +15 -0
- package/dist/tensor_util-DV-FP5Q3.js +523 -0
- package/dist/tfjs_backend-kNyO5L2d.js +653 -0
- package/dist/tile-BzyEiF-F.js +13 -0
- package/dist/tokeniser/CharTokeniser.js +1 -1
- package/dist/tokeniser/bpe.js +1 -1
- package/dist/training/Adam.d.ts +2 -1
- package/dist/training/Adam.js +12 -28
- package/dist/training/AdamExt.d.ts +1 -0
- package/dist/training/AdamExt.js +2 -2
- package/dist/training/DatasetBuilder.js +3 -20
- package/dist/training/FullTrainer.js +55 -48
- package/dist/training/Trainer.d.ts +11 -6
- package/dist/training/Trainer.js +51 -39
- package/dist/training/sparseCrossEntropy.js +3 -3
- package/dist/transpose-DKELTqhe.js +38 -0
- package/dist/utilities/arrayClose.js +7 -7
- package/dist/utilities/dummy.js +35 -27
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/packed.d.ts +7 -0
- package/dist/utilities/packed.js +716 -0
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/sentences.d.ts +5 -0
- package/dist/utilities/sentences.js +41 -0
- package/dist/utilities/weights.js +2 -2
- package/dist/variable-Bhn5bHYv.js +7 -0
- package/dist/{webgpu_program-DkQJOJSd.js → webgpu_program-Cigz-7RF.js} +15 -44
- package/dist/webgpu_util-BBCnKm2X.js +65 -0
- package/dist/zeros-2gldETuK.js +14 -0
- package/package.json +4 -3
- package/dist/Reshape-Bowtk9BP.js +0 -127
- package/dist/Reshape-DUqYftGC.js +0 -30
- package/dist/backend_util-CJIiDoV1.js +0 -749
- package/dist/broadcast_to-DzlNweb8.js +0 -44
- package/dist/concat-B912vBbo.js +0 -33
- package/dist/dropout-C-csYCLj.js +0 -193
- package/dist/exports_initializers-B8iZMgQ0.js +0 -16
- package/dist/gather-Dnpgw-YQ.js +0 -25
- package/dist/index-BzFyqcy-.js +0 -4457
- package/dist/index-C1rx_Ajs.js +0 -12076
- package/dist/kernel_funcs_utils-DKLK0Mg3.js +0 -466
- package/dist/log_sum_exp-DO6z8tSE.js +0 -103
- package/dist/mat_mul-DzjTFx-u.js +0 -27
- package/dist/mod-Dobti4j4.js +0 -27
- package/dist/ones-tIJeHlq-.js +0 -29
- package/dist/ops/fusedSoftmax.d.ts +0 -2
- package/dist/ops/fusedSoftmax.js +0 -10
- package/dist/ops/grads/fusedSoftmax.js +0 -22
- package/dist/ops-LuCMAnmM.js +0 -1525
- package/dist/random_width-CXVRloNK.js +0 -13670
- package/dist/range-CWcz7xFA.js +0 -26
- package/dist/reciprocal-C4rNcM-S.js +0 -25
- package/dist/relu-BjCh_SYb.js +0 -25
- package/dist/reshape-CnIwVG1c.js +0 -25
- package/dist/selu_util-OtRzVwW5.js +0 -719
- package/dist/shared-DmRsFyaJ.js +0 -3134
- package/dist/sin-gpDNRxE0.js +0 -47
- package/dist/slice-d0Vo9XTN.js +0 -28
- package/dist/softmax-D7Jj3p_P.js +0 -28
- package/dist/split-DK2k5eHf.js +0 -25
- package/dist/stack-DFatutCx.js +0 -27
- package/dist/sum-CJ0ULhmt.js +0 -27
- package/dist/tensor1d-vML0r3q6.js +0 -27
- package/dist/tensor2d-D76QGjF3.js +0 -30
- package/dist/tensor4d-Df1WlVDY.js +0 -30
- package/dist/webgpu_util-pLEV9tks.js +0 -80
- package/dist/zeros-Bj5rMYA7.js +0 -52
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
import { l as B, j as G, az as K, aa as z, at as W, aA as V, ag as N, au as F, u as S } from "./index-BzFyqcy-.js";
|
|
2
|
-
import { u as O, f as Y } from "./gpgpu_math-CDaYiyE_.js";
|
|
3
|
-
import { f as v } from "./backend_util-CJIiDoV1.js";
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
* =============================================================================
|
|
19
|
-
*/
|
|
20
|
-
function H(t, e) {
|
|
21
|
-
return ["x", "y", "z", "w", "u", "v"].slice(0, e).map((s) => `${t}.${s}`);
|
|
22
|
-
}
|
|
23
|
-
function Z(t, e) {
|
|
24
|
-
return e === 1 ? [t] : H(t, e);
|
|
25
|
-
}
|
|
26
|
-
function pe(t, e) {
|
|
27
|
-
if (t === 1)
|
|
28
|
-
return "rc";
|
|
29
|
-
let s = "";
|
|
30
|
-
for (let r = 0; r < t; r++)
|
|
31
|
-
s += e[r], r < t - 1 && (s += ",");
|
|
32
|
-
return s;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @license
|
|
36
|
-
* Copyright 2017 Google LLC. All Rights Reserved.
|
|
37
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
38
|
-
* you may not use this file except in compliance with the License.
|
|
39
|
-
* You may obtain a copy of the License at
|
|
40
|
-
*
|
|
41
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
-
*
|
|
43
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
44
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
45
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
46
|
-
* See the License for the specific language governing permissions and
|
|
47
|
-
* limitations under the License.
|
|
48
|
-
* =============================================================================
|
|
49
|
-
*/
|
|
50
|
-
class q {
|
|
51
|
-
constructor(e, s) {
|
|
52
|
-
this.variableNames = ["A"], this.outputShape = e, this.enableShapeUniforms = O(this.outputShape.length), this.userCode = `
|
|
53
|
-
float unaryOperation(float x) {
|
|
54
|
-
${s}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
void main() {
|
|
58
|
-
float x = getAAtOutCoords();
|
|
59
|
-
float y = unaryOperation(x);
|
|
60
|
-
|
|
61
|
-
setOutput(y);
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const T = "if (isnan(x)) return x;", j = "return x;", de = "return abs(x);", M = "return (x >= 0.0) ? x : (exp(x) - 1.0);", J = T + `
|
|
67
|
-
return (x < 0.0) ? 0.0 : x;
|
|
68
|
-
`, Q = T + `
|
|
69
|
-
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
70
|
-
`, he = "return x;", X = "return 1.0 / (1.0 + exp(-1.0 * x));";
|
|
71
|
-
/**
|
|
72
|
-
* @license
|
|
73
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
74
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
75
|
-
* you may not use this file except in compliance with the License.
|
|
76
|
-
* You may obtain a copy of the License at
|
|
77
|
-
*
|
|
78
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
79
|
-
*
|
|
80
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
81
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
82
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
83
|
-
* See the License for the specific language governing permissions and
|
|
84
|
-
* limitations under the License.
|
|
85
|
-
* =============================================================================
|
|
86
|
-
*/
|
|
87
|
-
const ee = "return x;", te = `
|
|
88
|
-
vec4 result;
|
|
89
|
-
|
|
90
|
-
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
|
|
91
|
-
result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
|
|
92
|
-
result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
|
|
93
|
-
result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
|
|
94
|
-
|
|
95
|
-
return result;
|
|
96
|
-
`, se = `
|
|
97
|
-
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
98
|
-
bvec4 isNaN = isnan(x);
|
|
99
|
-
|
|
100
|
-
result.r = isNaN.r ? x.r : result.r;
|
|
101
|
-
result.g = isNaN.g ? x.g : result.g;
|
|
102
|
-
result.b = isNaN.b ? x.b : result.b;
|
|
103
|
-
result.a = isNaN.a ? x.a : result.a;
|
|
104
|
-
|
|
105
|
-
return result;
|
|
106
|
-
`, ae = `
|
|
107
|
-
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
108
|
-
bvec4 isNaN = isnan(x);
|
|
109
|
-
|
|
110
|
-
result.r = isNaN.r ? x.r : result.r;
|
|
111
|
-
result.g = isNaN.g ? x.g : result.g;
|
|
112
|
-
result.b = isNaN.b ? x.b : result.b;
|
|
113
|
-
result.a = isNaN.a ? x.a : result.a;
|
|
114
|
-
|
|
115
|
-
return result;
|
|
116
|
-
`, re = "return 1.0 / (1.0 + exp(-1.0 * x));";
|
|
117
|
-
class ne {
|
|
118
|
-
constructor(e, s) {
|
|
119
|
-
this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e, this.enableShapeUniforms = O(this.outputShape.length), this.userCode = `
|
|
120
|
-
vec4 unaryOperation(vec4 x) {
|
|
121
|
-
${s}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
void main() {
|
|
125
|
-
vec4 x = getAAtOutCoords();
|
|
126
|
-
vec4 y = unaryOperation(x);
|
|
127
|
-
|
|
128
|
-
setOutput(y);
|
|
129
|
-
}
|
|
130
|
-
`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* @license
|
|
135
|
-
* Copyright 2017 Google LLC. All Rights Reserved.
|
|
136
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
137
|
-
* you may not use this file except in compliance with the License.
|
|
138
|
-
* You may obtain a copy of the License at
|
|
139
|
-
*
|
|
140
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
141
|
-
*
|
|
142
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
143
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
144
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
145
|
-
* See the License for the specific language governing permissions and
|
|
146
|
-
* limitations under the License.
|
|
147
|
-
* =============================================================================
|
|
148
|
-
*/
|
|
149
|
-
const fe = `
|
|
150
|
-
if (isnan(a)) return a;
|
|
151
|
-
if (isnan(b)) return b;
|
|
152
|
-
`;
|
|
153
|
-
class b {
|
|
154
|
-
constructor(e, s, r) {
|
|
155
|
-
this.variableNames = ["A", "B"], this.outputShape = B(s, r), this.enableShapeUniforms = O(this.outputShape.length), this.userCode = `
|
|
156
|
-
float binaryOperation(float a, float b) {
|
|
157
|
-
${e}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
void main() {
|
|
161
|
-
float a = getAAtOutCoords();
|
|
162
|
-
float b = getBAtOutCoords();
|
|
163
|
-
setOutput(binaryOperation(a, b));
|
|
164
|
-
}
|
|
165
|
-
`;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* @license
|
|
170
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
171
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
172
|
-
* you may not use this file except in compliance with the License.
|
|
173
|
-
* You may obtain a copy of the License at
|
|
174
|
-
*
|
|
175
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
176
|
-
*
|
|
177
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
178
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
179
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
180
|
-
* See the License for the specific language governing permissions and
|
|
181
|
-
* limitations under the License.
|
|
182
|
-
* =============================================================================
|
|
183
|
-
*/
|
|
184
|
-
const xe = `
|
|
185
|
-
result.r = isNaN.r ? NAN : result.r;
|
|
186
|
-
result.g = isNaN.g ? NAN : result.g;
|
|
187
|
-
result.b = isNaN.b ? NAN : result.b;
|
|
188
|
-
result.a = isNaN.a ? NAN : result.a;
|
|
189
|
-
`;
|
|
190
|
-
class E {
|
|
191
|
-
constructor(e, s, r, u = !1) {
|
|
192
|
-
this.variableNames = ["A", "B"], this.supportsBroadcasting = !0, this.packedInputs = !0, this.packedOutput = !0, this.outputShape = B(s, r);
|
|
193
|
-
const n = this.outputShape.length;
|
|
194
|
-
this.enableShapeUniforms = O(n);
|
|
195
|
-
let o = "";
|
|
196
|
-
if (u)
|
|
197
|
-
if (n === 0 || G(this.outputShape) === 1)
|
|
198
|
-
o = `
|
|
199
|
-
result.y = 0.;
|
|
200
|
-
result.z = 0.;
|
|
201
|
-
result.w = 0.;
|
|
202
|
-
`;
|
|
203
|
-
else if (o = `
|
|
204
|
-
${Y(n)} coords = getOutputCoords();
|
|
205
|
-
`, n === 1)
|
|
206
|
-
this.enableShapeUniforms ? o += `
|
|
207
|
-
result.y = (coords + 1) >= outShape ? 0. : result.y;
|
|
208
|
-
result.z = 0.;
|
|
209
|
-
result.w = 0.;
|
|
210
|
-
` : o += `
|
|
211
|
-
result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;
|
|
212
|
-
result.z = 0.;
|
|
213
|
-
result.w = 0.;
|
|
214
|
-
`;
|
|
215
|
-
else {
|
|
216
|
-
const a = Z("coords", n);
|
|
217
|
-
this.enableShapeUniforms ? o += `
|
|
218
|
-
bool nextRowOutOfBounds =
|
|
219
|
-
(${a[n - 2]} + 1) >= outShape[${n} - 2];
|
|
220
|
-
bool nextColOutOfBounds =
|
|
221
|
-
(${a[n - 1]} + 1) >= outShape[${n} - 1];
|
|
222
|
-
result.y = nextColOutOfBounds ? 0. : result.y;
|
|
223
|
-
result.z = nextRowOutOfBounds ? 0. : result.z;
|
|
224
|
-
result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
|
|
225
|
-
` : o += `
|
|
226
|
-
bool nextRowOutOfBounds =
|
|
227
|
-
(${a[n - 2]} + 1) >= ${this.outputShape[n - 2]};
|
|
228
|
-
bool nextColOutOfBounds =
|
|
229
|
-
(${a[n - 1]} + 1) >= ${this.outputShape[n - 1]};
|
|
230
|
-
result.y = nextColOutOfBounds ? 0. : result.y;
|
|
231
|
-
result.z = nextRowOutOfBounds ? 0. : result.z;
|
|
232
|
-
result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
|
|
233
|
-
`;
|
|
234
|
-
}
|
|
235
|
-
this.userCode = `
|
|
236
|
-
vec4 binaryOperation(vec4 a, vec4 b) {
|
|
237
|
-
${e}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
void main() {
|
|
241
|
-
vec4 a = getAAtOutCoords();
|
|
242
|
-
vec4 b = getBAtOutCoords();
|
|
243
|
-
|
|
244
|
-
vec4 result = binaryOperation(a, b);
|
|
245
|
-
${o}
|
|
246
|
-
|
|
247
|
-
setOutput(result);
|
|
248
|
-
}
|
|
249
|
-
`;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* @license
|
|
254
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
255
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
256
|
-
* you may not use this file except in compliance with the License.
|
|
257
|
-
* You may obtain a copy of the License at
|
|
258
|
-
*
|
|
259
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
260
|
-
*
|
|
261
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
262
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
263
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
264
|
-
* See the License for the specific language governing permissions and
|
|
265
|
-
* limitations under the License.
|
|
266
|
-
* =============================================================================
|
|
267
|
-
*/
|
|
268
|
-
function P(t) {
|
|
269
|
-
const { inputs: e, backend: s } = t, { x: r } = e;
|
|
270
|
-
return s.incRef(r.dataId), { dataId: r.dataId, shape: r.shape, dtype: r.dtype };
|
|
271
|
-
}
|
|
272
|
-
const ge = {
|
|
273
|
-
kernelName: K,
|
|
274
|
-
backendName: "webgl",
|
|
275
|
-
kernelFunc: P
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* @license
|
|
279
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
280
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
281
|
-
* you may not use this file except in compliance with the License.
|
|
282
|
-
* You may obtain a copy of the License at
|
|
283
|
-
*
|
|
284
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
285
|
-
*
|
|
286
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
287
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
288
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
289
|
-
* See the License for the specific language governing permissions and
|
|
290
|
-
* limitations under the License.
|
|
291
|
-
* =============================================================================
|
|
292
|
-
*/
|
|
293
|
-
function L(t) {
|
|
294
|
-
const { inputs: e, backend: s } = t, { real: r, imag: u } = e, n = s.makeTensorInfo(r.shape, "complex64"), o = s.texData.get(n.dataId), i = P({ inputs: { x: r }, backend: s }), a = P({ inputs: { x: u }, backend: s });
|
|
295
|
-
return o.complexTensorInfos = { real: i, imag: a }, n;
|
|
296
|
-
}
|
|
297
|
-
const me = {
|
|
298
|
-
kernelName: z,
|
|
299
|
-
backendName: "webgl",
|
|
300
|
-
kernelFunc: L
|
|
301
|
-
};
|
|
302
|
-
/**
|
|
303
|
-
* @license
|
|
304
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
305
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
306
|
-
* you may not use this file except in compliance with the License.
|
|
307
|
-
* You may obtain a copy of the License at
|
|
308
|
-
*
|
|
309
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
310
|
-
*
|
|
311
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
312
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
313
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
314
|
-
* See the License for the specific language governing permissions and
|
|
315
|
-
* limitations under the License.
|
|
316
|
-
* =============================================================================
|
|
317
|
-
*/
|
|
318
|
-
const w = "return (a < 0.) ? b * a : a;", R = `
|
|
319
|
-
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
320
|
-
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
321
|
-
`;
|
|
322
|
-
function oe(t) {
|
|
323
|
-
const { inputs: e, backend: s, attrs: r } = t, { x: u } = e, { alpha: n } = r, o = s.makeTensorInfo([], "float32", V(n, "float32")), i = N().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new E(R, u.shape, o.shape) : new b(w, u.shape, o.shape), a = s.runWebGLProgram(i, [u, o], "float32");
|
|
324
|
-
return s.disposeIntermediateTensorInfo(o), a;
|
|
325
|
-
}
|
|
326
|
-
const be = {
|
|
327
|
-
kernelName: W,
|
|
328
|
-
backendName: "webgl",
|
|
329
|
-
kernelFunc: oe
|
|
330
|
-
};
|
|
331
|
-
/**
|
|
332
|
-
* @license
|
|
333
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
334
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
335
|
-
* you may not use this file except in compliance with the License.
|
|
336
|
-
* You may obtain a copy of the License at
|
|
337
|
-
*
|
|
338
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
339
|
-
*
|
|
340
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
341
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
342
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
343
|
-
* See the License for the specific language governing permissions and
|
|
344
|
-
* limitations under the License.
|
|
345
|
-
* =============================================================================
|
|
346
|
-
*/
|
|
347
|
-
const k = "return (a < 0.) ? b * a : a;", U = `
|
|
348
|
-
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
349
|
-
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
350
|
-
`;
|
|
351
|
-
function ue(t) {
|
|
352
|
-
const { inputs: e, backend: s } = t, { x: r, alpha: u } = e, n = N().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new E(U, r.shape, u.shape) : new b(k, r.shape, u.shape);
|
|
353
|
-
return s.runWebGLProgram(n, [r, u], "float32");
|
|
354
|
-
}
|
|
355
|
-
const Ne = {
|
|
356
|
-
kernelName: F,
|
|
357
|
-
backendName: "webgl",
|
|
358
|
-
kernelFunc: ue
|
|
359
|
-
};
|
|
360
|
-
/**
|
|
361
|
-
* @license
|
|
362
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
363
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
364
|
-
* you may not use this file except in compliance with the License.
|
|
365
|
-
* You may obtain a copy of the License at
|
|
366
|
-
*
|
|
367
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
368
|
-
*
|
|
369
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
370
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
371
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
372
|
-
* See the License for the specific language governing permissions and
|
|
373
|
-
* limitations under the License.
|
|
374
|
-
* =============================================================================
|
|
375
|
-
*/
|
|
376
|
-
const Oe = "if (isnan(x)) return x;";
|
|
377
|
-
function ye({ opSnippet: t, packedOpSnippet: e, cpuKernelImpl: s, dtype: r }) {
|
|
378
|
-
return ({ inputs: u, backend: n }) => {
|
|
379
|
-
const { x: o } = u, i = n, a = r || o.dtype;
|
|
380
|
-
if (i.shouldExecuteOnCPU([o]) && s != null) {
|
|
381
|
-
const d = i.texData.get(o.dataId), y = s(d.values, a);
|
|
382
|
-
return i.makeTensorInfo(o.shape, a, y);
|
|
383
|
-
}
|
|
384
|
-
const c = N().getBool("WEBGL_PACK_UNARY_OPERATIONS") && e != null;
|
|
385
|
-
let l;
|
|
386
|
-
return c ? l = new ne(o.shape, e) : l = new q(o.shape, t), i.runWebGLProgram(l, [o], a);
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
function Ae({ opSnippet: t, packedOpSnippet: e, checkOutOfBounds: s = !1, supportsComplex: r = !1, cpuKernelImpl: u, dtype: n }) {
|
|
390
|
-
return ({ inputs: o, backend: i }) => {
|
|
391
|
-
const { a, b: c } = o, l = i;
|
|
392
|
-
if (r && a.dtype === "complex64") {
|
|
393
|
-
const h = l.texData.get(a.dataId), f = l.texData.get(c.dataId), [g, m] = [
|
|
394
|
-
[h.complexTensorInfos.real, f.complexTensorInfos.real],
|
|
395
|
-
[h.complexTensorInfos.imag, f.complexTensorInfos.imag]
|
|
396
|
-
].map((C) => {
|
|
397
|
-
const [p, x] = C, $ = {
|
|
398
|
-
dataId: p.dataId,
|
|
399
|
-
dtype: p.dtype,
|
|
400
|
-
shape: a.shape
|
|
401
|
-
}, _ = {
|
|
402
|
-
dataId: x.dataId,
|
|
403
|
-
dtype: x.dtype,
|
|
404
|
-
shape: c.shape
|
|
405
|
-
}, D = new b(t, a.shape, c.shape);
|
|
406
|
-
return l.runWebGLProgram(D, [$, _], S(p.dtype, x.dtype));
|
|
407
|
-
}), I = L({ inputs: { real: g, imag: m }, backend: l });
|
|
408
|
-
return l.disposeIntermediateTensorInfo(g), l.disposeIntermediateTensorInfo(m), I;
|
|
409
|
-
}
|
|
410
|
-
const d = n || S(a.dtype, c.dtype);
|
|
411
|
-
if ((a.dtype === "string" || c.dtype === "string" || l.shouldExecuteOnCPU([a, c])) && u != null) {
|
|
412
|
-
const h = l.texData.get(a.dataId).values, f = l.texData.get(c.dataId).values, g = a.dtype === "string" ? (
|
|
413
|
-
// tslint:disable-next-line: no-any
|
|
414
|
-
v(h)
|
|
415
|
-
) : h, m = a.dtype === "string" ? (
|
|
416
|
-
// tslint:disable-next-line: no-any
|
|
417
|
-
v(f)
|
|
418
|
-
) : f, [I, C] = u(a.shape, c.shape, g, m, d), p = l.makeTensorInfo(C, d), x = l.texData.get(p.dataId);
|
|
419
|
-
return x.values = I, p;
|
|
420
|
-
}
|
|
421
|
-
const y = N().getBool("WEBGL_PACK_BINARY_OPERATIONS") && e != null;
|
|
422
|
-
let A;
|
|
423
|
-
return y ? A = new E(e, a.shape, c.shape, s) : A = new b(t, a.shape, c.shape), l.runWebGLProgram(A, [a, c], d);
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
function Ie(t, e = !1) {
|
|
427
|
-
if (t === "linear")
|
|
428
|
-
return e ? ee : j;
|
|
429
|
-
if (t === "relu")
|
|
430
|
-
return e ? se : J;
|
|
431
|
-
if (t === "elu")
|
|
432
|
-
return e ? te : M;
|
|
433
|
-
if (t === "relu6")
|
|
434
|
-
return e ? ae : Q;
|
|
435
|
-
if (t === "prelu")
|
|
436
|
-
return e ? U : k;
|
|
437
|
-
if (t === "leakyrelu")
|
|
438
|
-
return e ? R : w;
|
|
439
|
-
if (t === "sigmoid")
|
|
440
|
-
return e ? re : X;
|
|
441
|
-
throw new Error(`Activation ${t} has not been implemented for the WebGL backend.`);
|
|
442
|
-
}
|
|
443
|
-
export {
|
|
444
|
-
de as A,
|
|
445
|
-
E as B,
|
|
446
|
-
T as C,
|
|
447
|
-
ne as U,
|
|
448
|
-
Z as a,
|
|
449
|
-
Ae as b,
|
|
450
|
-
pe as c,
|
|
451
|
-
he as d,
|
|
452
|
-
q as e,
|
|
453
|
-
L as f,
|
|
454
|
-
H as g,
|
|
455
|
-
b as h,
|
|
456
|
-
P as i,
|
|
457
|
-
fe as j,
|
|
458
|
-
xe as k,
|
|
459
|
-
Oe as l,
|
|
460
|
-
Ie as m,
|
|
461
|
-
me as n,
|
|
462
|
-
ge as o,
|
|
463
|
-
be as p,
|
|
464
|
-
Ne as q,
|
|
465
|
-
ye as u
|
|
466
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { E as r, F as x, G as p, ah as h, ai as E, aj as $, p as d, c as S, q as K } from "./index-BzFyqcy-.js";
|
|
2
|
-
import { e as _ } from "./axis_util-TbGYJ208.js";
|
|
3
|
-
import { r as m } from "./reshape-CnIwVG1c.js";
|
|
4
|
-
import { s as T } from "./sum-CJ0ULhmt.js";
|
|
5
|
-
/**
|
|
6
|
-
* @license
|
|
7
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
8
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License.
|
|
10
|
-
* You may obtain a copy of the License at
|
|
11
|
-
*
|
|
12
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
* See the License for the specific language governing permissions and
|
|
18
|
-
* limitations under the License.
|
|
19
|
-
* =============================================================================
|
|
20
|
-
*/
|
|
21
|
-
function b(s, o = null, n = !1) {
|
|
22
|
-
const t = { x: x(s, "x", "max") }, e = { reductionIndices: o, keepDims: n };
|
|
23
|
-
return p.runKernel(h, t, e);
|
|
24
|
-
}
|
|
25
|
-
const G = /* @__PURE__ */ r({ max_: b });
|
|
26
|
-
/**
|
|
27
|
-
* @license
|
|
28
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
29
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
30
|
-
* you may not use this file except in compliance with the License.
|
|
31
|
-
* You may obtain a copy of the License at
|
|
32
|
-
*
|
|
33
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
-
*
|
|
35
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
36
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
37
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
38
|
-
* See the License for the specific language governing permissions and
|
|
39
|
-
* limitations under the License.
|
|
40
|
-
* =============================================================================
|
|
41
|
-
*/
|
|
42
|
-
function I(s) {
|
|
43
|
-
const n = { x: x(s, "x", "exp") };
|
|
44
|
-
return p.runKernel(E, n);
|
|
45
|
-
}
|
|
46
|
-
const M = /* @__PURE__ */ r({ exp_: I });
|
|
47
|
-
/**
|
|
48
|
-
* @license
|
|
49
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
50
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
51
|
-
* you may not use this file except in compliance with the License.
|
|
52
|
-
* You may obtain a copy of the License at
|
|
53
|
-
*
|
|
54
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
55
|
-
*
|
|
56
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
57
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
58
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
59
|
-
* See the License for the specific language governing permissions and
|
|
60
|
-
* limitations under the License.
|
|
61
|
-
* =============================================================================
|
|
62
|
-
*/
|
|
63
|
-
function N(s) {
|
|
64
|
-
const n = { x: x(s, "x", "log", "float32") };
|
|
65
|
-
return p.runKernel($, n);
|
|
66
|
-
}
|
|
67
|
-
const j = /* @__PURE__ */ r({ log_: N });
|
|
68
|
-
/**
|
|
69
|
-
* @license
|
|
70
|
-
* Copyright 2020 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 q(s, o = null, n = !1) {
|
|
85
|
-
const a = x(s, "x", "logSumExp"), t = d(o, a.shape), e = G(
|
|
86
|
-
a,
|
|
87
|
-
t,
|
|
88
|
-
!0
|
|
89
|
-
/* keepDims */
|
|
90
|
-
), i = S(a, e), l = M(i), f = T(l, t), u = j(f), c = K(m(e, u.shape), u);
|
|
91
|
-
if (n) {
|
|
92
|
-
const g = _(c.shape, t);
|
|
93
|
-
return m(c, g);
|
|
94
|
-
}
|
|
95
|
-
return c;
|
|
96
|
-
}
|
|
97
|
-
const F = /* @__PURE__ */ r({ logSumExp_: q });
|
|
98
|
-
export {
|
|
99
|
-
j as a,
|
|
100
|
-
M as e,
|
|
101
|
-
F as l,
|
|
102
|
-
G as m
|
|
103
|
-
};
|
package/dist/mat_mul-DzjTFx-u.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { E as m, F as s, Q as c, G as M, U as p } from "./index-BzFyqcy-.js";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
* =============================================================================
|
|
17
|
-
*/
|
|
18
|
-
function f(e, n, o = !1, l = !1) {
|
|
19
|
-
let a = s(e, "a", "matMul"), t = s(n, "b", "matMul");
|
|
20
|
-
[a, t] = c(a, t);
|
|
21
|
-
const r = { a, b: t }, u = { transposeA: o, transposeB: l };
|
|
22
|
-
return M.runKernel(p, r, u);
|
|
23
|
-
}
|
|
24
|
-
const i = /* @__PURE__ */ m({ matMul_: f });
|
|
25
|
-
export {
|
|
26
|
-
i as m
|
|
27
|
-
};
|
package/dist/mod-Dobti4j4.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { E as r, F as s, Q as m, G as c, Y as d } from "./index-BzFyqcy-.js";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
* =============================================================================
|
|
17
|
-
*/
|
|
18
|
-
function p(t, e) {
|
|
19
|
-
let o = s(t, "a", "mod"), a = s(e, "b", "mod");
|
|
20
|
-
[o, a] = m(o, a);
|
|
21
|
-
const n = { a: o, b: a };
|
|
22
|
-
return c.runKernel(d, n);
|
|
23
|
-
}
|
|
24
|
-
const b = /* @__PURE__ */ r({ mod_: p });
|
|
25
|
-
export {
|
|
26
|
-
b as m
|
|
27
|
-
};
|
package/dist/ones-tIJeHlq-.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { M as n, N as t, j as m, G as i } from "./index-BzFyqcy-.js";
|
|
2
|
-
import { z as c, c as f } from "./zeros-Bj5rMYA7.js";
|
|
3
|
-
/**
|
|
4
|
-
* @license
|
|
5
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
* =============================================================================
|
|
18
|
-
*/
|
|
19
|
-
function l(o, r = "float32") {
|
|
20
|
-
if (n(o), r === "complex64") {
|
|
21
|
-
const s = l(o, "float32"), a = c(o, "float32");
|
|
22
|
-
return f(s, a);
|
|
23
|
-
}
|
|
24
|
-
const e = t(m(o), r);
|
|
25
|
-
return i.makeTensor(e, o, r);
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
l as o
|
|
29
|
-
};
|
package/dist/ops/fusedSoftmax.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { e as t } from "../index-BzFyqcy-.js";
|
|
2
|
-
import "./cpu/fusedSoftmax.js";
|
|
3
|
-
import "./webgl/fusedSoftmax.js";
|
|
4
|
-
import "./grads/fusedSoftmax.js";
|
|
5
|
-
function p(r, e, o) {
|
|
6
|
-
return t().runKernel("FusedSoftmax", { logits: r }, { dim: -1, dropoutRate: e, seed: o });
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
p as fusedSoftmax
|
|
10
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { i as f, a as i, c as l } from "../../index-BzFyqcy-.js";
|
|
2
|
-
import { mulDrop as g } from "../mulDrop.js";
|
|
3
|
-
import { s as T } from "../../sum-CJ0ULhmt.js";
|
|
4
|
-
const Y = {
|
|
5
|
-
kernelName: "FusedSoftmax",
|
|
6
|
-
outputsToSave: [!0],
|
|
7
|
-
gradFunc: (o, n, a) => {
|
|
8
|
-
const [s] = n, { dim: c, dropoutRate: t, seed: e } = a, p = !0, r = t && e ? g(o, s, t, e) : i(o, s);
|
|
9
|
-
return {
|
|
10
|
-
logits: () => {
|
|
11
|
-
const m = T(r, [c], p), u = i(m, s);
|
|
12
|
-
m.dispose();
|
|
13
|
-
const d = l(r, u);
|
|
14
|
-
return u.dispose(), d;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
f(Y);
|
|
20
|
-
export {
|
|
21
|
-
Y as softmaxGradConfig
|
|
22
|
-
};
|