@genai-fi/nanogpt 0.19.0 → 0.20.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/package.json +9 -10
- package/dist/Generator.d.ts +0 -82
- package/dist/Generator.js +0 -11941
- package/dist/RealDiv-CGwv0liw.js +0 -365
- package/dist/Reshape-BW__R4mZ.js +0 -79
- package/dist/Reshape-CPBkTIH2.js +0 -14
- package/dist/TeachableLLM.d.ts +0 -70
- package/dist/TeachableLLM.js +0 -273
- package/dist/Trainer.d.ts +0 -43
- package/dist/Trainer.js +0 -244
- package/dist/_commonjsHelpers-ByX85dGu.js +0 -33
- package/dist/axis_util-GTVlo58H.js +0 -55
- package/dist/backend.d.ts +0 -2
- package/dist/backend.js +0 -13
- package/dist/backend_util-GaFarB78.js +0 -425
- package/dist/backend_webgpu-BqASlsbV.js +0 -545
- package/dist/binary_op_util-pKXltfxI.js +0 -192
- package/dist/broadcast_to-eS93CCN_.js +0 -28
- package/dist/checks/appendCache.d.ts +0 -1
- package/dist/checks/appendCache.js +0 -22
- package/dist/checks/attentionMask.d.ts +0 -1
- package/dist/checks/attentionMask.js +0 -37
- package/dist/checks/check.d.ts +0 -9
- package/dist/checks/check.js +0 -20
- package/dist/checks/gelu.d.ts +0 -1
- package/dist/checks/gelu.js +0 -18
- package/dist/checks/index.d.ts +0 -26
- package/dist/checks/index.js +0 -28
- package/dist/checks/matMulGelu.d.ts +0 -1
- package/dist/checks/matMulGelu.js +0 -28
- package/dist/checks/normRMS.d.ts +0 -1
- package/dist/checks/normRMS.js +0 -16
- package/dist/checks/normRMSGrad.d.ts +0 -1
- package/dist/checks/normRMSGrad.js +0 -12
- package/dist/checks/packUnpack.d.ts +0 -1
- package/dist/checks/packUnpack.js +0 -18
- package/dist/checks/qkv.d.ts +0 -1
- package/dist/checks/qkv.js +0 -34
- package/dist/checks/rope.d.ts +0 -1
- package/dist/checks/rope.js +0 -36
- package/dist/checks/weights.d.ts +0 -14
- package/dist/checks/weights.js +0 -31
- package/dist/clip_by_value-DDA7rrcT.js +0 -12
- package/dist/complex-DI35Q-gW.js +0 -11
- package/dist/complex_util-Yc1A_gV1.js +0 -55
- package/dist/concat-CAQpCret.js +0 -17
- package/dist/concat_util-D18dJ4fD.js +0 -22
- package/dist/data/docx.d.ts +0 -2
- package/dist/data/docx.js +0 -15
- package/dist/data/parquet.d.ts +0 -2
- package/dist/data/parquet.js +0 -17
- package/dist/data/pdf.d.ts +0 -2
- package/dist/data/pdf.js +0 -14
- package/dist/data/textLoader.d.ts +0 -7
- package/dist/data/textLoader.js +0 -108
- package/dist/dataset-CGGp1z9P.js +0 -1124
- package/dist/dropout_util--NxWuYg2.js +0 -27
- package/dist/expand_dims-Bkd1YD5x.js +0 -11
- package/dist/exports_initializers-CYzKLjN7.js +0 -7
- package/dist/floor-BQtb-Azg.js +0 -9
- package/dist/gather-qIqEqaGn.js +0 -9
- package/dist/gelu-B220X1Go.js +0 -26
- package/dist/gpgpu_math-BwvV12df.js +0 -2022
- package/dist/index-CUXkjxiT.js +0 -3516
- package/dist/index-CieiGp4Y.js +0 -349
- package/dist/index-CjOWnMXP.js +0 -7308
- package/dist/index-Cp39cXWe.js +0 -1016
- package/dist/index-D5v913EJ.js +0 -4
- package/dist/index-DmeWGGmS.js +0 -1074
- package/dist/index-DvYrXKkX.js +0 -113
- package/dist/index-Ksja3su6.js +0 -151
- package/dist/index-xuotMAFm.js +0 -118
- package/dist/inference/types.d.ts +0 -16
- package/dist/inference/types.js +0 -1
- package/dist/jszip.min-BZhlzntC.js +0 -2313
- package/dist/kernel_funcs_utils-pq0CK9co.js +0 -306
- package/dist/layers/BaseLayer.d.ts +0 -44
- package/dist/layers/BaseLayer.js +0 -74
- package/dist/layers/CausalSelfAttention.d.ts +0 -39
- package/dist/layers/CausalSelfAttention.js +0 -86
- package/dist/layers/LoRA.d.ts +0 -14
- package/dist/layers/LoRA.js +0 -58
- package/dist/layers/MLP.d.ts +0 -17
- package/dist/layers/MLP.js +0 -44
- package/dist/layers/PositionEmbedding.d.ts +0 -8
- package/dist/layers/PositionEmbedding.js +0 -31
- package/dist/layers/RMSNorm.d.ts +0 -12
- package/dist/layers/RMSNorm.js +0 -22
- package/dist/layers/RoPECache.d.ts +0 -18
- package/dist/layers/RoPECache.js +0 -50
- package/dist/layers/TiedEmbedding.d.ts +0 -13
- package/dist/layers/TiedEmbedding.js +0 -36
- package/dist/layers/TransformerBlock.d.ts +0 -27
- package/dist/layers/TransformerBlock.js +0 -40
- package/dist/layers/WeightStore.d.ts +0 -20
- package/dist/layers/WeightStore.js +0 -76
- package/dist/loader/load.d.ts +0 -6
- package/dist/loader/load.js +0 -68
- package/dist/loader/loadHF.d.ts +0 -8
- package/dist/loader/loadHF.js +0 -22
- package/dist/loader/loadTransformers.d.ts +0 -4
- package/dist/loader/loadTransformers.js +0 -44
- package/dist/loader/loadZipMeta.d.ts +0 -3
- package/dist/loader/loadZipMeta.js +0 -16
- package/dist/loader/newZipLoad.d.ts +0 -3
- package/dist/loader/newZipLoad.js +0 -31
- package/dist/loader/oldZipLoad.d.ts +0 -9
- package/dist/loader/oldZipLoad.js +0 -80
- package/dist/loader/save.d.ts +0 -16
- package/dist/loader/save.js +0 -90
- package/dist/loader/types.d.ts +0 -67
- package/dist/loader/types.js +0 -1
- package/dist/main.d.ts +0 -50
- package/dist/main.js +0 -109
- package/dist/matMul16-BcVC_E62.js +0 -80
- package/dist/matMulGelu-JNLZqKQp.js +0 -163
- package/dist/mat_mul-DhG0Newp.js +0 -11
- package/dist/mod-CSdCpRjf.js +0 -11
- package/dist/models/NanoGPTV1.d.ts +0 -16
- package/dist/models/NanoGPTV1.js +0 -99
- package/dist/models/NanoGPTV2.d.ts +0 -16
- package/dist/models/NanoGPTV2.js +0 -90
- package/dist/models/config.d.ts +0 -27
- package/dist/models/config.js +0 -50
- package/dist/models/factory.d.ts +0 -3
- package/dist/models/factory.js +0 -16
- package/dist/models/model.d.ts +0 -44
- package/dist/models/model.js +0 -134
- package/dist/non_max_suppression_impl-B2W7YjZB.js +0 -102
- package/dist/not_equal-hurPF26l.js +0 -64
- package/dist/ones-BytntneX.js +0 -14
- package/dist/ops/adamAdjust.d.ts +0 -2
- package/dist/ops/adamAdjust.js +0 -9
- package/dist/ops/adamMoments.d.ts +0 -2
- package/dist/ops/adamMoments.js +0 -9
- package/dist/ops/add16.d.ts +0 -2
- package/dist/ops/add16.js +0 -9
- package/dist/ops/appendCache.d.ts +0 -2
- package/dist/ops/appendCache.js +0 -22
- package/dist/ops/attentionMask.d.ts +0 -2
- package/dist/ops/attentionMask.js +0 -10
- package/dist/ops/concat16.d.ts +0 -2
- package/dist/ops/concat16.js +0 -9
- package/dist/ops/cpu/adamAdjust.d.ts +0 -1
- package/dist/ops/cpu/adamAdjust.js +0 -18
- package/dist/ops/cpu/adamMoments.d.ts +0 -1
- package/dist/ops/cpu/adamMoments.js +0 -16
- package/dist/ops/cpu/appendCache.d.ts +0 -1
- package/dist/ops/cpu/appendCache.js +0 -23
- package/dist/ops/cpu/attentionMask.d.ts +0 -1
- package/dist/ops/cpu/attentionMask.js +0 -22
- package/dist/ops/cpu/fusedSoftmax.d.ts +0 -9
- package/dist/ops/cpu/fusedSoftmax.js +0 -29
- package/dist/ops/cpu/gatherSub.d.ts +0 -1
- package/dist/ops/cpu/gatherSub.js +0 -18
- package/dist/ops/cpu/gelu.d.ts +0 -1
- package/dist/ops/cpu/gelu.js +0 -40
- package/dist/ops/cpu/matMul16.d.ts +0 -1
- package/dist/ops/cpu/matMul16.js +0 -15
- package/dist/ops/cpu/matMulGelu.d.ts +0 -1
- package/dist/ops/cpu/matMulGelu.js +0 -53
- package/dist/ops/cpu/matMulMul.d.ts +0 -1
- package/dist/ops/cpu/matMulMul.js +0 -23
- package/dist/ops/cpu/mulDropout.d.ts +0 -1
- package/dist/ops/cpu/mulDropout.js +0 -23
- package/dist/ops/cpu/normRMS.d.ts +0 -1
- package/dist/ops/cpu/normRMS.js +0 -39
- package/dist/ops/cpu/qkv.d.ts +0 -5
- package/dist/ops/cpu/qkv.js +0 -41
- package/dist/ops/cpu/rope.d.ts +0 -6
- package/dist/ops/cpu/rope.js +0 -38
- package/dist/ops/cpu/scatterSub.d.ts +0 -1
- package/dist/ops/cpu/scatterSub.js +0 -23
- package/dist/ops/dot16.d.ts +0 -2
- package/dist/ops/dot16.js +0 -42
- package/dist/ops/dropout.d.ts +0 -2
- package/dist/ops/dropout.js +0 -14
- package/dist/ops/dropout16.d.ts +0 -2
- package/dist/ops/dropout16.js +0 -25
- package/dist/ops/gatherSub.d.ts +0 -2
- package/dist/ops/gatherSub.js +0 -9
- package/dist/ops/gelu.d.ts +0 -3
- package/dist/ops/gelu.js +0 -8
- package/dist/ops/globalNorm.d.ts +0 -2
- package/dist/ops/globalNorm.js +0 -13
- package/dist/ops/grads/add16.d.ts +0 -1
- package/dist/ops/grads/add16.js +0 -26
- package/dist/ops/grads/attentionMask.d.ts +0 -1
- package/dist/ops/grads/attentionMask.js +0 -21
- package/dist/ops/grads/dropout16.d.ts +0 -1
- package/dist/ops/grads/dropout16.js +0 -2
- package/dist/ops/grads/gelu.d.ts +0 -2
- package/dist/ops/grads/gelu.js +0 -5
- package/dist/ops/grads/matMul16.d.ts +0 -2
- package/dist/ops/grads/matMul16.js +0 -9
- package/dist/ops/grads/matMulGelu.d.ts +0 -1
- package/dist/ops/grads/matMulGelu.js +0 -17
- package/dist/ops/grads/mul16.d.ts +0 -1
- package/dist/ops/grads/mul16.js +0 -4
- package/dist/ops/grads/normRMS.d.ts +0 -3
- package/dist/ops/grads/normRMS.js +0 -33
- package/dist/ops/grads/pack16.d.ts +0 -2
- package/dist/ops/grads/pack16.js +0 -6
- package/dist/ops/grads/qkv.d.ts +0 -3
- package/dist/ops/grads/qkv.js +0 -34
- package/dist/ops/grads/rope.d.ts +0 -2
- package/dist/ops/grads/rope.js +0 -5
- package/dist/ops/grads/softmax16.d.ts +0 -2
- package/dist/ops/grads/softmax16.js +0 -25
- package/dist/ops/grads/unpack16.d.ts +0 -2
- package/dist/ops/grads/unpack16.js +0 -5
- package/dist/ops/grads/utils.d.ts +0 -4
- package/dist/ops/grads/utils.js +0 -14
- package/dist/ops/log.d.ts +0 -0
- package/dist/ops/log.js +0 -1
- package/dist/ops/matMul16.d.ts +0 -15
- package/dist/ops/matMul16.js +0 -13
- package/dist/ops/matMulGelu.d.ts +0 -3
- package/dist/ops/matMulGelu.js +0 -14
- package/dist/ops/matMulMul.d.ts +0 -2
- package/dist/ops/matMulMul.js +0 -9
- package/dist/ops/mul16.d.ts +0 -2
- package/dist/ops/mul16.js +0 -39
- package/dist/ops/mulDrop.d.ts +0 -2
- package/dist/ops/mulDrop.js +0 -9
- package/dist/ops/normRMS.d.ts +0 -2
- package/dist/ops/normRMS.js +0 -19
- package/dist/ops/pack16.d.ts +0 -2
- package/dist/ops/pack16.js +0 -5
- package/dist/ops/qkv.d.ts +0 -2
- package/dist/ops/qkv.js +0 -10
- package/dist/ops/reshape16.d.ts +0 -2
- package/dist/ops/reshape16.js +0 -41
- package/dist/ops/rope.d.ts +0 -3
- package/dist/ops/rope.js +0 -7
- package/dist/ops/scatterSub.d.ts +0 -2
- package/dist/ops/scatterSub.js +0 -9
- package/dist/ops/slice16.d.ts +0 -2
- package/dist/ops/slice16.js +0 -9
- package/dist/ops/softmax16.d.ts +0 -2
- package/dist/ops/softmax16.js +0 -9
- package/dist/ops/sub16.d.ts +0 -2
- package/dist/ops/sub16.js +0 -8
- package/dist/ops/sum16.d.ts +0 -2
- package/dist/ops/sum16.js +0 -13
- package/dist/ops/transpose16.d.ts +0 -3
- package/dist/ops/transpose16.js +0 -40
- package/dist/ops/unpack16.d.ts +0 -2
- package/dist/ops/unpack16.js +0 -6
- package/dist/ops/webgl/adamAdjust.d.ts +0 -1
- package/dist/ops/webgl/adamAdjust.js +0 -49
- package/dist/ops/webgl/adamMoments.d.ts +0 -1
- package/dist/ops/webgl/adamMoments.js +0 -40
- package/dist/ops/webgl/appendCache.d.ts +0 -1
- package/dist/ops/webgl/appendCache.js +0 -44
- package/dist/ops/webgl/attentionMask.d.ts +0 -1
- package/dist/ops/webgl/attentionMask.js +0 -45
- package/dist/ops/webgl/dropout16.d.ts +0 -1
- package/dist/ops/webgl/dropout16.js +0 -11
- package/dist/ops/webgl/fusedSoftmax.d.ts +0 -11
- package/dist/ops/webgl/fusedSoftmax.js +0 -80
- package/dist/ops/webgl/gatherSub.d.ts +0 -1
- package/dist/ops/webgl/gatherSub.js +0 -27
- package/dist/ops/webgl/gelu.d.ts +0 -2
- package/dist/ops/webgl/gelu.js +0 -50
- package/dist/ops/webgl/log.d.ts +0 -17
- package/dist/ops/webgl/log.js +0 -23
- package/dist/ops/webgl/matMul16.d.ts +0 -1
- package/dist/ops/webgl/matMul16.js +0 -45
- package/dist/ops/webgl/matMulGelu.d.ts +0 -21
- package/dist/ops/webgl/matMulGelu.js +0 -9
- package/dist/ops/webgl/matMulMul.d.ts +0 -14
- package/dist/ops/webgl/matMulMul.js +0 -28
- package/dist/ops/webgl/mulDropout.d.ts +0 -1
- package/dist/ops/webgl/mulDropout.js +0 -41
- package/dist/ops/webgl/normRMS.d.ts +0 -1
- package/dist/ops/webgl/normRMS.js +0 -93
- package/dist/ops/webgl/qkv.d.ts +0 -1
- package/dist/ops/webgl/qkv.js +0 -46
- package/dist/ops/webgl/rope.d.ts +0 -1
- package/dist/ops/webgl/rope.js +0 -56
- package/dist/ops/webgl/scatterSub.d.ts +0 -1
- package/dist/ops/webgl/scatterSub.js +0 -27
- package/dist/ops/webgpu/adamAdjust.d.ts +0 -1
- package/dist/ops/webgpu/adamAdjust.js +0 -57
- package/dist/ops/webgpu/adamMoments.d.ts +0 -1
- package/dist/ops/webgpu/adamMoments.js +0 -60
- package/dist/ops/webgpu/add16.d.ts +0 -1
- package/dist/ops/webgpu/add16.js +0 -13
- package/dist/ops/webgpu/appendCache.d.ts +0 -1
- package/dist/ops/webgpu/appendCache.js +0 -105
- package/dist/ops/webgpu/attentionMask.d.ts +0 -1
- package/dist/ops/webgpu/attentionMask.js +0 -26
- package/dist/ops/webgpu/attentionMask32_program.d.ts +0 -19
- package/dist/ops/webgpu/attentionMask32_program.js +0 -54
- package/dist/ops/webgpu/clipScale.d.ts +0 -1
- package/dist/ops/webgpu/clipScale.js +0 -58
- package/dist/ops/webgpu/concat16.d.ts +0 -19
- package/dist/ops/webgpu/concat16.js +0 -126
- package/dist/ops/webgpu/dropout16.d.ts +0 -1
- package/dist/ops/webgpu/dropout16.js +0 -51
- package/dist/ops/webgpu/gatherSub.d.ts +0 -1
- package/dist/ops/webgpu/gatherSub.js +0 -39
- package/dist/ops/webgpu/gelu.d.ts +0 -14
- package/dist/ops/webgpu/gelu.js +0 -141
- package/dist/ops/webgpu/index.d.ts +0 -0
- package/dist/ops/webgpu/index.js +0 -26
- package/dist/ops/webgpu/matMul16.d.ts +0 -1
- package/dist/ops/webgpu/matMul16.js +0 -65
- package/dist/ops/webgpu/matMul16_program.d.ts +0 -42
- package/dist/ops/webgpu/matMul16_program.js +0 -343
- package/dist/ops/webgpu/mul16.d.ts +0 -1
- package/dist/ops/webgpu/mul16.js +0 -13
- package/dist/ops/webgpu/norm2.d.ts +0 -1
- package/dist/ops/webgpu/norm2.js +0 -76
- package/dist/ops/webgpu/normRMS.d.ts +0 -1
- package/dist/ops/webgpu/normRMS.js +0 -34
- package/dist/ops/webgpu/normRMS16_program.d.ts +0 -10
- package/dist/ops/webgpu/normRMS16_program.js +0 -25
- package/dist/ops/webgpu/normRMS32_program.d.ts +0 -10
- package/dist/ops/webgpu/normRMS32_program.js +0 -25
- package/dist/ops/webgpu/normRMSGrad.d.ts +0 -1
- package/dist/ops/webgpu/normRMSGrad.js +0 -284
- package/dist/ops/webgpu/pack16.d.ts +0 -1
- package/dist/ops/webgpu/pack16.js +0 -18
- package/dist/ops/webgpu/pack16_program.d.ts +0 -19
- package/dist/ops/webgpu/pack16_program.js +0 -92
- package/dist/ops/webgpu/qkv.d.ts +0 -1
- package/dist/ops/webgpu/qkv.js +0 -24
- package/dist/ops/webgpu/rope.d.ts +0 -1
- package/dist/ops/webgpu/rope.js +0 -135
- package/dist/ops/webgpu/scatterSub.d.ts +0 -1
- package/dist/ops/webgpu/scatterSub.js +0 -40
- package/dist/ops/webgpu/slice16.d.ts +0 -7
- package/dist/ops/webgpu/slice16.js +0 -69
- package/dist/ops/webgpu/softmax16.d.ts +0 -17
- package/dist/ops/webgpu/softmax16.js +0 -21
- package/dist/ops/webgpu/softmax16_program.d.ts +0 -13
- package/dist/ops/webgpu/softmax16_program.js +0 -73
- package/dist/ops/webgpu/softmax16_subgroup_program.d.ts +0 -17
- package/dist/ops/webgpu/softmax16_subgroup_program.js +0 -75
- package/dist/ops/webgpu/softmax16grad.d.ts +0 -1
- package/dist/ops/webgpu/softmax16grad.js +0 -37
- package/dist/ops/webgpu/sub16.d.ts +0 -1
- package/dist/ops/webgpu/sub16.js +0 -13
- package/dist/ops/webgpu/sum16.d.ts +0 -1
- package/dist/ops/webgpu/sum16.js +0 -38
- package/dist/ops/webgpu/transpose16.d.ts +0 -1
- package/dist/ops/webgpu/transpose16.js +0 -34
- package/dist/ops/webgpu/transpose16_program.d.ts +0 -16
- package/dist/ops/webgpu/transpose16_program.js +0 -50
- package/dist/ops/webgpu/transpose16_shared_program.d.ts +0 -15
- package/dist/ops/webgpu/transpose16_shared_program.js +0 -70
- package/dist/ops/webgpu/unpack16.d.ts +0 -1
- package/dist/ops/webgpu/unpack16.js +0 -48
- package/dist/ops/webgpu/utils/binary_op.d.ts +0 -35
- package/dist/ops/webgpu/utils/binary_op.js +0 -139
- package/dist/ops/webgpu/utils/deviceInfo.d.ts +0 -7
- package/dist/ops/webgpu/utils/deviceInfo.js +0 -11
- package/dist/ops/webgpu/utils/reductions.d.ts +0 -43
- package/dist/ops/webgpu/utils/reductions.js +0 -275
- package/dist/ops-CsXeTq1P.js +0 -476
- package/dist/pack16-bqltoUlR.js +0 -39
- package/dist/papaparse.min-C0cScC2i.js +0 -418
- package/dist/parquet-Bqjmp2vo.js +0 -44231
- package/dist/patches/webgpu_backend.d.ts +0 -18
- package/dist/patches/webgpu_backend.js +0 -56
- package/dist/patches/webgpu_base.d.ts +0 -21
- package/dist/patches/webgpu_base.js +0 -34
- package/dist/patches/webgpu_program.d.ts +0 -36
- package/dist/patches/webgpu_program.js +0 -400
- package/dist/pdf-NIhmP3sq.js +0 -19477
- package/dist/rand_util-CZ7yLoUm.js +0 -50
- package/dist/random_normal-IBRrha8a.js +0 -14
- package/dist/random_width-DN5ZtQkM.js +0 -9796
- package/dist/range-C-CjF-LI.js +0 -10
- package/dist/relu-J_X6MUzx.js +0 -9
- package/dist/reshape-BDOuCSNW.js +0 -9
- package/dist/resize_nearest_neighbor-BojqlfRe.js +0 -150
- package/dist/rope-DcrZM_e6.js +0 -24
- package/dist/scatter_nd_util-ByNJaL6I.js +0 -46
- package/dist/segment_util-Dasb2Zaf.js +0 -43
- package/dist/selu_util-BLhIqRkw.js +0 -44
- package/dist/shared-3agzAqQ_.js +0 -53
- package/dist/shared-CagdqkLh.js +0 -2143
- package/dist/slice-BzS11Qh0.js +0 -12
- package/dist/slice_util-CC35pLmT.js +0 -153
- package/dist/softmax-D4q1LJN7.js +0 -12
- package/dist/split-C2Sj255c.js +0 -9
- package/dist/squeeze-ho4wLUek.js +0 -10
- package/dist/stack-DudVrtmG.js +0 -11
- package/dist/step-BTxPtq1r.js +0 -261
- package/dist/sum-BpiwSWvg.js +0 -11
- package/dist/tensor-BWFldCso.js +0 -8
- package/dist/tensor1d-LMGMIUlr.js +0 -11
- package/dist/tensor2d-BnXMKScO.js +0 -14
- package/dist/tensor4d-C6UCG_u8.js +0 -14
- package/dist/tfjs_backend-BGnG-ppu.js +0 -654
- package/dist/tile-CFy-xTO6.js +0 -11
- package/dist/tokeniser/BaseTokeniser.d.ts +0 -33
- package/dist/tokeniser/BaseTokeniser.js +0 -124
- package/dist/tokeniser/CharTokeniser.d.ts +0 -24
- package/dist/tokeniser/CharTokeniser.js +0 -107
- package/dist/tokeniser/bpe.d.ts +0 -28
- package/dist/tokeniser/bpe.js +0 -173
- package/dist/tokeniser/messages.d.ts +0 -61
- package/dist/tokeniser/messages.js +0 -1
- package/dist/tokeniser/type.d.ts +0 -34
- package/dist/tokeniser/type.js +0 -1
- package/dist/training/AdamW.d.ts +0 -36
- package/dist/training/AdamW.js +0 -138
- package/dist/training/BasicTrainer.d.ts +0 -63
- package/dist/training/BasicTrainer.js +0 -265
- package/dist/training/DatasetBuilder.d.ts +0 -26
- package/dist/training/DatasetBuilder.js +0 -86
- package/dist/training/Evaluator.d.ts +0 -19
- package/dist/training/Evaluator.js +0 -39
- package/dist/training/LRScheduler.d.ts +0 -12
- package/dist/training/LRScheduler.js +0 -34
- package/dist/training/PreTrainer.d.ts +0 -11
- package/dist/training/PreTrainer.js +0 -20
- package/dist/training/SFTTrainer.d.ts +0 -12
- package/dist/training/SFTTrainer.js +0 -22
- package/dist/training/loss.d.ts +0 -3
- package/dist/training/loss.js +0 -24
- package/dist/training/orthoGrad.d.ts +0 -2
- package/dist/training/orthoGrad.js +0 -10
- package/dist/training/sparseCrossEntropy.d.ts +0 -7
- package/dist/training/sparseCrossEntropy.js +0 -69
- package/dist/training/tasks/ConversationTask.d.ts +0 -18
- package/dist/training/tasks/ConversationTask.js +0 -40
- package/dist/training/tasks/PretrainingTask.d.ts +0 -17
- package/dist/training/tasks/PretrainingTask.js +0 -47
- package/dist/training/tasks/StartSentenceTask.d.ts +0 -18
- package/dist/training/tasks/StartSentenceTask.js +0 -49
- package/dist/training/tasks/Task.d.ts +0 -22
- package/dist/training/tasks/Task.js +0 -68
- package/dist/training/tasks/splitter.d.ts +0 -5
- package/dist/training/tasks/splitter.js +0 -21
- package/dist/training/types.d.ts +0 -78
- package/dist/training/types.js +0 -1
- package/dist/training/validation.d.ts +0 -17
- package/dist/training/validation.js +0 -84
- package/dist/transpose-9kRxIXWR.js +0 -36
- package/dist/unsorted_segment_sum-DJvk5xnh.js +0 -277
- package/dist/utilities/arrayClose.d.ts +0 -1
- package/dist/utilities/arrayClose.js +0 -20
- package/dist/utilities/datasetID.d.ts +0 -2
- package/dist/utilities/datasetID.js +0 -21
- package/dist/utilities/dummy.d.ts +0 -9
- package/dist/utilities/dummy.js +0 -43
- package/dist/utilities/multinomialCPU.d.ts +0 -2
- package/dist/utilities/multinomialCPU.js +0 -13
- package/dist/utilities/naming.d.ts +0 -4
- package/dist/utilities/naming.js +0 -1
- package/dist/utilities/packed.d.ts +0 -4
- package/dist/utilities/packed.js +0 -15
- package/dist/utilities/parameters.d.ts +0 -11
- package/dist/utilities/parameters.js +0 -57
- package/dist/utilities/performance.d.ts +0 -2
- package/dist/utilities/performance.js +0 -16
- package/dist/utilities/profile.d.ts +0 -17
- package/dist/utilities/profile.js +0 -38
- package/dist/utilities/safetensors.d.ts +0 -3
- package/dist/utilities/safetensors.js +0 -83
- package/dist/utilities/sentences.d.ts +0 -5
- package/dist/utilities/sentences.js +0 -41
- package/dist/utilities/tokenParse.d.ts +0 -1
- package/dist/utilities/tokenParse.js +0 -21
- package/dist/utilities/topP.d.ts +0 -1
- package/dist/utilities/topP.js +0 -13
- package/dist/utilities/waitForModel.d.ts +0 -2
- package/dist/utilities/waitForModel.js +0 -12
- package/dist/utilities/weights.d.ts +0 -12
- package/dist/utilities/weights.js +0 -45
- package/dist/utilities/yielder.d.ts +0 -1
- package/dist/utilities/yielder.js +0 -7
- package/dist/variable-Ck482e3n.js +0 -7
- package/dist/webgpu_program-B4HmApL1.js +0 -525
- package/dist/webgpu_util-DYlGSwOJ.js +0 -64
- package/dist/zeros-DvZpK8s6.js +0 -13
- package/dist/zeros_like-CWjDdwr-.js +0 -721
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { b as u, c as m, e as l } from "../../webgpu_program-B4HmApL1.js";
|
|
2
|
-
import { f, c as g } from "../../webgpu_util-DYlGSwOJ.js";
|
|
3
|
-
import { c as S, U as k } from "../../index-CUXkjxiT.js";
|
|
4
|
-
import { p as y, a as $ } from "../../slice_util-CC35pLmT.js";
|
|
5
|
-
function x(o) {
|
|
6
|
-
switch (o) {
|
|
7
|
-
case 1:
|
|
8
|
-
return "1D";
|
|
9
|
-
case 2:
|
|
10
|
-
return "2D";
|
|
11
|
-
case 3:
|
|
12
|
-
return "3D";
|
|
13
|
-
case 4:
|
|
14
|
-
return "4D";
|
|
15
|
-
}
|
|
16
|
-
return "";
|
|
17
|
-
}
|
|
18
|
-
class b {
|
|
19
|
-
variableNames = ["source"];
|
|
20
|
-
uniforms;
|
|
21
|
-
outputShape;
|
|
22
|
-
shaderKey;
|
|
23
|
-
rank;
|
|
24
|
-
dispatchLayout;
|
|
25
|
-
dispatch;
|
|
26
|
-
workPerThread = 1;
|
|
27
|
-
workgroupSize = [64, 1, 1];
|
|
28
|
-
start;
|
|
29
|
-
size = !0;
|
|
30
|
-
constructor(e, t) {
|
|
31
|
-
this.outputShape = t, this.rank = t.length, this.dispatchLayout = f(this.outputShape), this.dispatch = g(this.dispatchLayout, this.outputShape, this.workgroupSize, [
|
|
32
|
-
this.workPerThread,
|
|
33
|
-
1,
|
|
34
|
-
1
|
|
35
|
-
]), this.start = e, this.uniforms = `start : ${u(e.length)}, `, this.shaderKey = "slice";
|
|
36
|
-
}
|
|
37
|
-
getUserCode() {
|
|
38
|
-
const e = u(this.rank);
|
|
39
|
-
let t;
|
|
40
|
-
return this.start.length === 1 ? t = this.outputShape.map(() => "sourceLoc = uniforms.start + coords;") : t = this.outputShape.map((r, s) => `sourceLoc.${c[s]} = uniforms.start.${m(s)} + coords.${c[s]};`), `
|
|
41
|
-
${l("index")} {
|
|
42
|
-
if (index < uniforms.size) {
|
|
43
|
-
var sourceLoc : ${e};
|
|
44
|
-
let coords = getCoordsFromIndex(index);
|
|
45
|
-
${t.join(`
|
|
46
|
-
`)}
|
|
47
|
-
result[index] = source[getIndexFromCoords${x(this.rank)}(sourceLoc, uniforms.sourceShape)];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const c = ["x", "y", "z", "w", "u", "v"];
|
|
54
|
-
function w(o) {
|
|
55
|
-
const { inputs: e, backend: t, attrs: n } = o, { x: r } = e, { begin: s, size: p } = n, [i, a] = y(r, s, p);
|
|
56
|
-
if ($(r, i, a), k(a) === 0)
|
|
57
|
-
return t.makeTensorInfo(a, r.dtype, []);
|
|
58
|
-
const h = new b(i, a), d = [{ type: "int32", data: i }];
|
|
59
|
-
return t.runWebGPUProgram(h, [r], r.dtype, d);
|
|
60
|
-
}
|
|
61
|
-
const C = {
|
|
62
|
-
kernelName: "Slice16",
|
|
63
|
-
backendName: "webgpu",
|
|
64
|
-
kernelFunc: w
|
|
65
|
-
};
|
|
66
|
-
S(C);
|
|
67
|
-
export {
|
|
68
|
-
w as slice
|
|
69
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2023 Google LLC.
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
* =============================================================================
|
|
16
|
-
*/
|
|
17
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { c as h, U as S, h as b } from "../../index-CUXkjxiT.js";
|
|
2
|
-
import { reshape16 as d } from "../reshape16.js";
|
|
3
|
-
import x from "./softmax16_program.js";
|
|
4
|
-
import k from "./softmax16_subgroup_program.js";
|
|
5
|
-
import l from "./utils/deviceInfo.js";
|
|
6
|
-
import { r as z } from "../../reshape-BDOuCSNW.js";
|
|
7
|
-
function F(a) {
|
|
8
|
-
const { inputs: t, backend: o, attrs: p } = a, { logits: e } = t, { dim: r } = p, m = o.subgroupMinSize, i = o.subgroupMaxSize, c = l(o).subgroupsSupported, s = z(e, [
|
|
9
|
-
S(e.shape) / e.shape[r],
|
|
10
|
-
e.shape[r]
|
|
11
|
-
]), u = c ? new k(s.shape, m, i) : new x(s.shape), f = o.runWebGPUProgram(u, [s], "packedF16");
|
|
12
|
-
s.dispose();
|
|
13
|
-
const n = b().makeTensorFromTensorInfo(f), g = d(n, e.shape);
|
|
14
|
-
return n.dispose(), g;
|
|
15
|
-
}
|
|
16
|
-
const I = {
|
|
17
|
-
kernelName: "Softmax16",
|
|
18
|
-
backendName: "webgpu",
|
|
19
|
-
kernelFunc: F
|
|
20
|
-
};
|
|
21
|
-
h(I);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { WebGPUProgram } from '@tensorflow/tfjs-backend-webgpu';
|
|
2
|
-
export default class SoftmaxProgram implements WebGPUProgram {
|
|
3
|
-
variableNames: string[];
|
|
4
|
-
outputShape: number[];
|
|
5
|
-
shaderKey: string;
|
|
6
|
-
dispatchLayout: {
|
|
7
|
-
x: number[];
|
|
8
|
-
};
|
|
9
|
-
dispatch: [number, number, number];
|
|
10
|
-
workgroupSize: [number, number, number];
|
|
11
|
-
constructor(outputShape: number[]);
|
|
12
|
-
getUserCode(): string;
|
|
13
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { e } from "../../webgpu_program-B4HmApL1.js";
|
|
2
|
-
import { f as o } from "../../webgpu_util-DYlGSwOJ.js";
|
|
3
|
-
class i {
|
|
4
|
-
variableNames = ["logits"];
|
|
5
|
-
outputShape;
|
|
6
|
-
shaderKey;
|
|
7
|
-
dispatchLayout;
|
|
8
|
-
dispatch;
|
|
9
|
-
workgroupSize;
|
|
10
|
-
constructor(r) {
|
|
11
|
-
this.outputShape = r, this.dispatchLayout = o(this.outputShape), this.dispatch = [this.outputShape[0], 1, 1], this.outputShape[1] >= 4096 ? this.workgroupSize = [256, 1, 1] : this.outputShape[1] < 64 ? this.workgroupSize = [32, 1, 1] : this.workgroupSize = [64, 1, 1], this.shaderKey = "softmax16";
|
|
12
|
-
}
|
|
13
|
-
getUserCode() {
|
|
14
|
-
return `
|
|
15
|
-
var<workgroup> buf : array<f32, ${this.workgroupSize[0]}>;
|
|
16
|
-
const blockSize = ${this.workgroupSize[0]};
|
|
17
|
-
${e("index")} {
|
|
18
|
-
let row = index / blockSize;
|
|
19
|
-
let tid = i32(localId.x);
|
|
20
|
-
let cols = uniforms.outShape[1];
|
|
21
|
-
let rowIdx = row * cols;
|
|
22
|
-
|
|
23
|
-
var threadMax = -3.402823e+38f;
|
|
24
|
-
for (var col = tid; col < cols; col += blockSize) {
|
|
25
|
-
let value = unpack2x16float(u32(logits[rowIdx + col]));
|
|
26
|
-
threadMax = max(threadMax, max(value.x, value.y));
|
|
27
|
-
}
|
|
28
|
-
buf[tid] = threadMax;
|
|
29
|
-
workgroupBarrier();
|
|
30
|
-
|
|
31
|
-
for (var currSize = blockSize >> 1; currSize > 0; currSize = currSize >> 1) {
|
|
32
|
-
if (tid < currSize) {
|
|
33
|
-
buf[tid] = max(buf[tid], buf[tid + currSize]);
|
|
34
|
-
}
|
|
35
|
-
workgroupBarrier();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let rowMaxShared: f32 = buf[0];
|
|
39
|
-
workgroupBarrier();
|
|
40
|
-
|
|
41
|
-
var threadSum = 0.0f;
|
|
42
|
-
for (var col = tid; col < cols; col += blockSize) {
|
|
43
|
-
let value = unpack2x16float(u32(logits[rowIdx + col]));
|
|
44
|
-
let subExp = exp(value.x - rowMaxShared);
|
|
45
|
-
threadSum += subExp;
|
|
46
|
-
let subExpY = exp(value.y - rowMaxShared);
|
|
47
|
-
threadSum += subExpY;
|
|
48
|
-
}
|
|
49
|
-
buf[tid] = threadSum;
|
|
50
|
-
workgroupBarrier();
|
|
51
|
-
|
|
52
|
-
for (var currSize = blockSize >> 1; currSize > 0; currSize = currSize >> 1) {
|
|
53
|
-
if (tid < currSize) {
|
|
54
|
-
buf[tid] = buf[tid] + buf[tid + currSize];
|
|
55
|
-
}
|
|
56
|
-
workgroupBarrier();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let rowSumShared: f32 = buf[0];
|
|
60
|
-
|
|
61
|
-
for (var col = tid; col < cols; col += blockSize) {
|
|
62
|
-
let value = unpack2x16float(u32(logits[rowIdx + col]));
|
|
63
|
-
let value1: f32 = exp(value.x - rowMaxShared) / rowSumShared;
|
|
64
|
-
let value2: f32 = exp(value.y - rowMaxShared) / rowSumShared;
|
|
65
|
-
result[rowIdx + col] = i32(pack2x16float(vec2<f32>(value1, value2)));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
export {
|
|
72
|
-
i as default
|
|
73
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { WebGPUProgram } from '@tensorflow/tfjs-backend-webgpu';
|
|
2
|
-
export default class SoftmaxSubgroupProgram implements WebGPUProgram {
|
|
3
|
-
variableNames: string[];
|
|
4
|
-
outputShape: number[];
|
|
5
|
-
shaderKey: string;
|
|
6
|
-
dispatchLayout: {
|
|
7
|
-
x: number[];
|
|
8
|
-
};
|
|
9
|
-
dispatch: [number, number, number];
|
|
10
|
-
workgroupSize: [number, number, number];
|
|
11
|
-
minSubgroupSize: number;
|
|
12
|
-
maxSubgroupSize: number;
|
|
13
|
-
subgroups: boolean;
|
|
14
|
-
subgroupBuiltins: boolean;
|
|
15
|
-
constructor(outputShape: number[], minSubgroupSize: number, maxSubgroupSize: number);
|
|
16
|
-
getUserCode(): string;
|
|
17
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { e as o } from "../../webgpu_program-B4HmApL1.js";
|
|
2
|
-
import { f as u } from "../../webgpu_util-DYlGSwOJ.js";
|
|
3
|
-
class i {
|
|
4
|
-
variableNames = ["logits"];
|
|
5
|
-
outputShape;
|
|
6
|
-
shaderKey;
|
|
7
|
-
dispatchLayout;
|
|
8
|
-
dispatch;
|
|
9
|
-
workgroupSize;
|
|
10
|
-
minSubgroupSize;
|
|
11
|
-
maxSubgroupSize;
|
|
12
|
-
subgroups = !0;
|
|
13
|
-
subgroupBuiltins = !1;
|
|
14
|
-
constructor(e, a, r) {
|
|
15
|
-
this.minSubgroupSize = a, this.maxSubgroupSize = r, this.outputShape = e, this.dispatchLayout = u(this.outputShape), this.dispatch = [this.outputShape[0], 1, 1], this.workgroupSize = [Math.min(64, r), 1, 1], a !== r && (this.subgroupBuiltins = !0, this.workgroupSize = [64, 1, 1]), this.shaderKey = "softmax16subgroup";
|
|
16
|
-
}
|
|
17
|
-
getUserCode() {
|
|
18
|
-
const e = this.maxSubgroupSize !== this.minSubgroupSize;
|
|
19
|
-
return `
|
|
20
|
-
${e ? `var<workgroup> bestValues : array<f32, ${this.workgroupSize[0]}>;` : ""}
|
|
21
|
-
const blockSize = ${this.workgroupSize[0]};
|
|
22
|
-
${o("index")} {
|
|
23
|
-
let row = index / blockSize;
|
|
24
|
-
let tid = i32(localId.x);
|
|
25
|
-
let cols = uniforms.outShape[1];
|
|
26
|
-
let rowIdx = row * cols;
|
|
27
|
-
|
|
28
|
-
var threadMax = -3.402823e+38f;
|
|
29
|
-
for (var col = tid; col < cols; col += blockSize) {
|
|
30
|
-
let value = unpack2x16float(u32(logits[rowIdx + col]));
|
|
31
|
-
threadMax = max(threadMax, max(value.x, value.y));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
threadMax = subgroupMax(threadMax);
|
|
35
|
-
${e ? `
|
|
36
|
-
let lane = localId.x % subgroupSize;
|
|
37
|
-
if (lane == 0) {
|
|
38
|
-
bestValues[localId.x / subgroupSize] = threadMax;
|
|
39
|
-
}
|
|
40
|
-
workgroupBarrier();
|
|
41
|
-
let numSubgroups = blockSize / subgroupSize;
|
|
42
|
-
threadMax = select(-3.402823e+38f, bestValues[lane], lane < numSubgroups);
|
|
43
|
-
threadMax = subgroupMax(threadMax);
|
|
44
|
-
workgroupBarrier();
|
|
45
|
-
` : ""}
|
|
46
|
-
|
|
47
|
-
var threadSum = 0.0f;
|
|
48
|
-
for (var col = tid; col < cols; col += blockSize) {
|
|
49
|
-
let value = unpack2x16float(u32(logits[rowIdx + col]));
|
|
50
|
-
let subExp = exp(value - threadMax);
|
|
51
|
-
threadSum += subExp.x + subExp.y;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
threadSum = subgroupAdd(threadSum);
|
|
55
|
-
${e ? `
|
|
56
|
-
if (lane == 0) {
|
|
57
|
-
bestValues[localId.x / subgroupSize] = threadSum;
|
|
58
|
-
}
|
|
59
|
-
workgroupBarrier();
|
|
60
|
-
threadSum = select(0.0f, bestValues[lane], lane < numSubgroups);
|
|
61
|
-
threadSum = subgroupAdd(threadSum);
|
|
62
|
-
` : ""}
|
|
63
|
-
|
|
64
|
-
for (var col = tid; col < cols; col += ${e ? "i32(subgroupSize)" : "blockSize"}) {
|
|
65
|
-
let value = unpack2x16float(u32(logits[rowIdx + col]));
|
|
66
|
-
let valuePair: vec2<f32> = exp(value - threadMax) / threadSum;
|
|
67
|
-
result[rowIdx + col] = i32(pack2x16float(valuePair));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
`;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
i as default
|
|
75
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { c as p } from "../../index-CUXkjxiT.js";
|
|
2
|
-
import { createReduceInfo as m, reduce as l, ReduceProgram as i } from "./utils/reductions.js";
|
|
3
|
-
import { isPackedTensor as n } from "../../utilities/packed.js";
|
|
4
|
-
import k from "./utils/deviceInfo.js";
|
|
5
|
-
class x extends i {
|
|
6
|
-
constructor(e, t) {
|
|
7
|
-
super(e, t, { reductionOp: "sum", elementwise: !0 }, !0), this.shaderKey = "SoftmaxGrad16", this.variableNames = ["dy", "softmaxOutput"], this.variableComponents = [1, 1];
|
|
8
|
-
}
|
|
9
|
-
getReadSnippet() {
|
|
10
|
-
return `
|
|
11
|
-
let d: vec2<f32> = unpack2x16float(u32(dy[index]));
|
|
12
|
-
let l: vec2<f32> = unpack2x16float(u32(softmaxOutput[index]));
|
|
13
|
-
return d * l;
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
getWriteSnippet() {
|
|
17
|
-
return `
|
|
18
|
-
let d: vec2<f32> = unpack2x16float(u32(dy[offset + k]));
|
|
19
|
-
let l: vec2<f32> = unpack2x16float(u32(softmaxOutput[offset + k]));
|
|
20
|
-
let outVal = l * (d - bestValue);
|
|
21
|
-
result[offset + k] = i32(pack2x16float(outVal));
|
|
22
|
-
`;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function b(o) {
|
|
26
|
-
const { dy: e, softmaxOutput: t } = o.inputs, r = o.backend, s = k(r), u = n(e), c = n(t);
|
|
27
|
-
if (!(u && c))
|
|
28
|
-
throw new Error("softmaxGradGPU: dy and softmaxOutput must be packed tensors");
|
|
29
|
-
const a = [e, t], f = m(a, -1), d = new x(s, f);
|
|
30
|
-
return l(d, a, r);
|
|
31
|
-
}
|
|
32
|
-
const v = {
|
|
33
|
-
kernelName: "Softmax16Grad",
|
|
34
|
-
backendName: "webgpu",
|
|
35
|
-
kernelFunc: b
|
|
36
|
-
};
|
|
37
|
-
p(v);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/ops/webgpu/sub16.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { c as t } from "../../index-CUXkjxiT.js";
|
|
2
|
-
import { BinaryOpProgram as s } from "./utils/binary_op.js";
|
|
3
|
-
import { B as c } from "../../binary_op_util-pKXltfxI.js";
|
|
4
|
-
function p(e) {
|
|
5
|
-
const { a: r, b: n } = e.inputs, o = e.backend, a = new s(c.SUB, r.shape, n.shape);
|
|
6
|
-
return o.runWebGPUProgram(a, [r, n], "packedF16");
|
|
7
|
-
}
|
|
8
|
-
const m = {
|
|
9
|
-
kernelName: "Sub16",
|
|
10
|
-
backendName: "webgpu",
|
|
11
|
-
kernelFunc: p
|
|
12
|
-
};
|
|
13
|
-
t(m);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/ops/webgpu/sum16.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createReduceInfo as h, reduce as g, ReduceProgram as x } from "./utils/reductions.js";
|
|
2
|
-
import { c as k, ah as A } from "../../index-CUXkjxiT.js";
|
|
3
|
-
import { isPackedTensor as P } from "../../utilities/packed.js";
|
|
4
|
-
import { transpose16 as b } from "../transpose16.js";
|
|
5
|
-
import I from "./utils/deviceInfo.js";
|
|
6
|
-
import { s as w } from "../../sum-BpiwSWvg.js";
|
|
7
|
-
import { a as D, b as K } from "../../axis_util-GTVlo58H.js";
|
|
8
|
-
class v extends x {
|
|
9
|
-
shaderKey = "sum16";
|
|
10
|
-
constructor(e, t, o) {
|
|
11
|
-
super(
|
|
12
|
-
e,
|
|
13
|
-
t,
|
|
14
|
-
{
|
|
15
|
-
reductionOp: "sum",
|
|
16
|
-
elementwise: !1
|
|
17
|
-
},
|
|
18
|
-
o
|
|
19
|
-
), o && (this.shaderKey += "_packed");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function y(r) {
|
|
23
|
-
const { x: e } = r.inputs, { axis: t, keepDims: o } = r.attrs, a = r.backend, c = [], u = I(a), m = P(e);
|
|
24
|
-
if (!m)
|
|
25
|
-
return w(e, t, o);
|
|
26
|
-
let n = A(t ?? -1, e.shape);
|
|
27
|
-
const i = D(n, e.shape.length);
|
|
28
|
-
let s = e;
|
|
29
|
-
i != null && (s = b(e, i), n = K(n.length, s.shape.length), c.push(s));
|
|
30
|
-
const p = h([s], -1), f = new v(u, p, m), d = g(f, [s], a);
|
|
31
|
-
return c.forEach((l) => l.dispose()), d;
|
|
32
|
-
}
|
|
33
|
-
const N = {
|
|
34
|
-
kernelName: "Sum16",
|
|
35
|
-
backendName: "webgpu",
|
|
36
|
-
kernelFunc: y
|
|
37
|
-
};
|
|
38
|
-
k(N);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { isPackedTensor as d } from "../../utilities/packed.js";
|
|
2
|
-
import { c as k, h as l } from "../../index-CUXkjxiT.js";
|
|
3
|
-
import { reshape16 as u } from "../reshape16.js";
|
|
4
|
-
import P from "./transpose16_shared_program.js";
|
|
5
|
-
import b from "./transpose16_program.js";
|
|
6
|
-
import { t as T } from "../../transpose-9kRxIXWR.js";
|
|
7
|
-
function w(p) {
|
|
8
|
-
const { inputs: h, attrs: i } = p, { x: e } = h, { perm: r } = i, a = p.backend, c = d(e);
|
|
9
|
-
if (c && r[r.length - 1] !== e.shape.length - 1) {
|
|
10
|
-
const o = e.shape.length, m = o === 4 ? r.map((s) => s - 1).filter((s) => s >= 0) : r, t = o === 4 ? u(e, [e.shape[0] * e.shape[1], e.shape[2], e.shape[3]]) : e, f = new P(t.shape, m), n = a.runWebGPUProgram(f, [t], "packedF16");
|
|
11
|
-
if (o === 4) {
|
|
12
|
-
t.dispose();
|
|
13
|
-
const s = l().makeTensorFromTensorInfo(n), g = u(s, [
|
|
14
|
-
e.shape[0],
|
|
15
|
-
e.shape[1],
|
|
16
|
-
n.shape[1],
|
|
17
|
-
n.shape[2]
|
|
18
|
-
]);
|
|
19
|
-
return s.dispose(), g;
|
|
20
|
-
}
|
|
21
|
-
return n;
|
|
22
|
-
}
|
|
23
|
-
if (c) {
|
|
24
|
-
const o = new b(e.shape, r);
|
|
25
|
-
return a.runWebGPUProgram(o, [e], "packedF16");
|
|
26
|
-
} else
|
|
27
|
-
return T(e, r);
|
|
28
|
-
}
|
|
29
|
-
const F = {
|
|
30
|
-
kernelName: "Transpose16",
|
|
31
|
-
backendName: "webgpu",
|
|
32
|
-
kernelFunc: w
|
|
33
|
-
};
|
|
34
|
-
k(F);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { WebGPUProgram } from '@tensorflow/tfjs-backend-webgpu';
|
|
2
|
-
export default class TransposeProgram16 implements WebGPUProgram {
|
|
3
|
-
variableNames: string[];
|
|
4
|
-
shaderKey: string;
|
|
5
|
-
outputShape: number[];
|
|
6
|
-
dispatchLayout: {
|
|
7
|
-
x: number[];
|
|
8
|
-
};
|
|
9
|
-
dispatch: [number, number, number];
|
|
10
|
-
workPerThread: number;
|
|
11
|
-
workgroupSize: [number, number, number];
|
|
12
|
-
newDim: number[];
|
|
13
|
-
size: boolean;
|
|
14
|
-
constructor(aShape: number[], newDim: number[]);
|
|
15
|
-
getUserCode(): string;
|
|
16
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { f as a, c as i } from "../../webgpu_util-DYlGSwOJ.js";
|
|
2
|
-
import { b as h, e as d, c as n } from "../../webgpu_program-B4HmApL1.js";
|
|
3
|
-
function p(r) {
|
|
4
|
-
const e = r.length;
|
|
5
|
-
if (e > 6)
|
|
6
|
-
throw Error(`Transpose for rank ${e} is not yet supported`);
|
|
7
|
-
const o = new Array(e);
|
|
8
|
-
for (let t = 0; t < r.length; t++)
|
|
9
|
-
o[r[t]] = `coords.${n(t)}`;
|
|
10
|
-
return o.join();
|
|
11
|
-
}
|
|
12
|
-
class l {
|
|
13
|
-
variableNames = ["A"];
|
|
14
|
-
shaderKey;
|
|
15
|
-
outputShape;
|
|
16
|
-
dispatchLayout;
|
|
17
|
-
dispatch;
|
|
18
|
-
workPerThread = 1;
|
|
19
|
-
workgroupSize = [64, 1, 1];
|
|
20
|
-
newDim;
|
|
21
|
-
size = !0;
|
|
22
|
-
constructor(e, o) {
|
|
23
|
-
const t = new Array(e.length);
|
|
24
|
-
for (let s = 0; s < t.length; s++)
|
|
25
|
-
t[s] = e[o[s]];
|
|
26
|
-
this.outputShape = t, this.dispatchLayout = a(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize, [
|
|
27
|
-
this.workPerThread,
|
|
28
|
-
1,
|
|
29
|
-
1
|
|
30
|
-
]), this.newDim = o, this.shaderKey = `transpose16_${o}`;
|
|
31
|
-
}
|
|
32
|
-
getUserCode() {
|
|
33
|
-
const e = h(this.outputShape.length), o = p(this.newDim);
|
|
34
|
-
return `
|
|
35
|
-
${d("index")} {
|
|
36
|
-
for(var i = 0; i < ${this.workPerThread}; i = i + 1) {
|
|
37
|
-
let flatIndex = index * ${this.workPerThread} + i;
|
|
38
|
-
if(flatIndex < uniforms.size) {
|
|
39
|
-
let coords = getCoordsFromIndex(flatIndex);
|
|
40
|
-
result[flatIndex] = A[getIndexFromCoords${this.outputShape.length}D(
|
|
41
|
-
${e}(${o}), uniforms.aShape)];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
`;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export {
|
|
49
|
-
l as default
|
|
50
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { WebGPUProgram } from '@tensorflow/tfjs-backend-webgpu/dist/webgpu_program';
|
|
2
|
-
export default class TransposeSharedProgram16 implements WebGPUProgram {
|
|
3
|
-
variableNames: string[];
|
|
4
|
-
outputShape: number[];
|
|
5
|
-
shaderKey: string;
|
|
6
|
-
dispatchLayout: {
|
|
7
|
-
x: number[];
|
|
8
|
-
y: number[];
|
|
9
|
-
z?: number[];
|
|
10
|
-
};
|
|
11
|
-
dispatch: [number, number, number];
|
|
12
|
-
workgroupSize: [number, number, number];
|
|
13
|
-
constructor(aShape: number[], newDim: number[]);
|
|
14
|
-
getUserCode(): string;
|
|
15
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { c as a } from "../../webgpu_util-DYlGSwOJ.js";
|
|
2
|
-
import { e as l } from "../../webgpu_program-B4HmApL1.js";
|
|
3
|
-
import { x as p } from "../../index-CUXkjxiT.js";
|
|
4
|
-
class n {
|
|
5
|
-
variableNames = ["A"];
|
|
6
|
-
outputShape;
|
|
7
|
-
shaderKey;
|
|
8
|
-
dispatchLayout;
|
|
9
|
-
dispatch;
|
|
10
|
-
// Note that the maximum number of workgroup invocations by webgpu is 256.
|
|
11
|
-
// Nick: Reduce to 8x8
|
|
12
|
-
workgroupSize = [8, 8, 1];
|
|
13
|
-
constructor(t, o) {
|
|
14
|
-
const i = t.length, e = new Array(i), r = t.slice();
|
|
15
|
-
r[r.length - 1] *= 2;
|
|
16
|
-
for (let u = 0; u < e.length; u++)
|
|
17
|
-
e[u] = r[o[u]];
|
|
18
|
-
e[e.length - 1] /= 2, this.outputShape = e, this.dispatchLayout = i === 2 ? { x: [0], y: [1] } : { x: [1], y: [2], z: [0] }, this.dispatch = a(this.dispatchLayout, this.outputShape, this.workgroupSize, [2, 1, 1]), this.shaderKey = `transposeShared16_${i}`;
|
|
19
|
-
}
|
|
20
|
-
getUserCode() {
|
|
21
|
-
const t = this.outputShape.length;
|
|
22
|
-
p(
|
|
23
|
-
this.workgroupSize[0] === this.workgroupSize[1],
|
|
24
|
-
() => `Must be a square tile, current tile shape is ${this.workgroupSize[0]} x ${this.workgroupSize[1]}`
|
|
25
|
-
);
|
|
26
|
-
const o = this.workgroupSize[0] * 2;
|
|
27
|
-
return `
|
|
28
|
-
var<workgroup> tile : array<array<f32, ${o + 1}>, ${o}>;
|
|
29
|
-
${l()} {
|
|
30
|
-
var x = i32(workgroupId.x) * ${o / 2} + i32(localId.x);
|
|
31
|
-
var y = i32(workgroupId.y) * ${o} + i32(localId.y);
|
|
32
|
-
let batch = ${t === 3 ? "i32(workgroupId.z)" : "0"};
|
|
33
|
-
let batchOffsetA = ${t === 3 ? "batch * uniforms.aShapeStrides[0]" : "0"};
|
|
34
|
-
let batchOffsetOut = ${t === 3 ? "batch * uniforms.outShapeStrides[0]" : "0"};
|
|
35
|
-
|
|
36
|
-
let inputWidth = uniforms.outShape[${t === 3 ? "1" : "0"}] / 2; // Output height
|
|
37
|
-
let inputHeight = uniforms.outShape[${t === 3 ? "2" : "1"}] * 2; // Output width
|
|
38
|
-
if (x < inputWidth && y < inputHeight) {
|
|
39
|
-
let unpackedA = unpack2x16float(u32(A[batchOffsetA + y * inputWidth + x]));
|
|
40
|
-
tile[localId.y][localId.x * 2] = unpackedA.x;
|
|
41
|
-
tile[localId.y][localId.x * 2 + 1] = unpackedA.y;
|
|
42
|
-
}
|
|
43
|
-
// Second load to cover the tile
|
|
44
|
-
y = y + ${this.workgroupSize[0]};
|
|
45
|
-
if (x < inputWidth && y < inputHeight) {
|
|
46
|
-
let unpackedA = unpack2x16float(u32(A[batchOffsetA + y * inputWidth + x]));
|
|
47
|
-
tile[localId.y + ${this.workgroupSize[0]}][localId.x * 2] = unpackedA.x;
|
|
48
|
-
tile[localId.y + ${this.workgroupSize[0]}][localId.x * 2 + 1] = unpackedA.y;
|
|
49
|
-
}
|
|
50
|
-
workgroupBarrier();
|
|
51
|
-
|
|
52
|
-
let outputWidth = uniforms.outShape[${t === 3 ? "2" : "1"}]; // Output width
|
|
53
|
-
let outputHeight = uniforms.outShape[${t === 3 ? "1" : "0"}] * 2; // Output height
|
|
54
|
-
x = i32(workgroupId.y) * ${o / 2} + i32(localId.x);
|
|
55
|
-
y = i32(workgroupId.x) * ${o} + i32(localId.y);
|
|
56
|
-
if (x < outputWidth && y < outputHeight) {
|
|
57
|
-
result[batchOffsetOut + y * outputWidth + x] = i32(pack2x16float(vec2<f32>(tile[localId.x * 2][localId.y], tile[localId.x * 2 + 1][localId.y])));
|
|
58
|
-
}
|
|
59
|
-
// Second store to cover the tile
|
|
60
|
-
y = y + ${this.workgroupSize[0]};
|
|
61
|
-
if (x < outputWidth && y < outputHeight) {
|
|
62
|
-
result[batchOffsetOut + y * outputWidth + x] = i32(pack2x16float(vec2<f32>(tile[localId.x * 2][localId.y + ${this.workgroupSize[0]}], tile[localId.x * 2 + 1][localId.y + ${this.workgroupSize[0]}])));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
export {
|
|
69
|
-
n as default
|
|
70
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { f as c, c as r } from "../../webgpu_util-DYlGSwOJ.js";
|
|
2
|
-
import { e as u } from "../../webgpu_program-B4HmApL1.js";
|
|
3
|
-
import { c as p } from "../../index-CUXkjxiT.js";
|
|
4
|
-
class l {
|
|
5
|
-
outputShape;
|
|
6
|
-
shaderKey = "Unpack16";
|
|
7
|
-
dispatchLayout;
|
|
8
|
-
dispatch;
|
|
9
|
-
workgroupSize = [64, 1, 1];
|
|
10
|
-
variableNames = ["x"];
|
|
11
|
-
size = !0;
|
|
12
|
-
uniforms;
|
|
13
|
-
outputComponent = 4;
|
|
14
|
-
variableComponents = [2];
|
|
15
|
-
scaling = !1;
|
|
16
|
-
constructor(t) {
|
|
17
|
-
this.outputShape = [...t.slice(0, -1), t[t.length - 1] * 2], this.dispatchLayout = c(this.outputShape), this.dispatch = r(this.dispatchLayout, this.outputShape, this.workgroupSize, [4, 1, 1]);
|
|
18
|
-
}
|
|
19
|
-
useScaling() {
|
|
20
|
-
this.shaderKey += "_Scaled", this.uniforms = "scaling : f32,", this.scaling = !0;
|
|
21
|
-
}
|
|
22
|
-
getUserCode() {
|
|
23
|
-
return `
|
|
24
|
-
${u("index")} {
|
|
25
|
-
let outIndex = index;
|
|
26
|
-
if (outIndex < uniforms.size) {
|
|
27
|
-
let xvec2 = x[index];
|
|
28
|
-
let v1 = vec4<f32>(
|
|
29
|
-
unpack2x16float(u32(xvec2.x)),
|
|
30
|
-
unpack2x16float(u32(xvec2.y))
|
|
31
|
-
) ${this.scaling ? "* uniforms.scaling" : ""};
|
|
32
|
-
result[outIndex] = v1;
|
|
33
|
-
}
|
|
34
|
-
}`;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function h(e) {
|
|
38
|
-
const { x: t } = e.inputs, { scaling: a } = e.attrs, i = e.backend, n = new l(t.shape), s = a !== 1;
|
|
39
|
-
s && n.useScaling();
|
|
40
|
-
const o = [{ type: "float32", data: [1 / a] }];
|
|
41
|
-
return i.runWebGPUProgram(n, [t], "float32", s ? o : void 0);
|
|
42
|
-
}
|
|
43
|
-
const d = {
|
|
44
|
-
kernelName: "Unpack16",
|
|
45
|
-
backendName: "webgpu",
|
|
46
|
-
kernelFunc: h
|
|
47
|
-
};
|
|
48
|
-
p(d);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { WebGPUProgram } from '@tensorflow/tfjs-backend-webgpu';
|
|
2
|
-
import { BinaryOpType } from '@tensorflow/tfjs-backend-webgpu/dist/binary_op_util';
|
|
3
|
-
export { BinaryOpType };
|
|
4
|
-
export declare class BinaryOpProgram implements WebGPUProgram {
|
|
5
|
-
dispatch: [number, number, number];
|
|
6
|
-
dispatchLayout: {
|
|
7
|
-
x: number[];
|
|
8
|
-
};
|
|
9
|
-
outputComponent: number;
|
|
10
|
-
op: BinaryOpType;
|
|
11
|
-
outputShape: number[];
|
|
12
|
-
shaderKey: string;
|
|
13
|
-
size: boolean;
|
|
14
|
-
variableNames: string[];
|
|
15
|
-
workgroupSize: [number, number, number];
|
|
16
|
-
variableComponents: number[];
|
|
17
|
-
constructor(op: BinaryOpType, aShape: number[], bShape: number[]);
|
|
18
|
-
getUserCode(): string;
|
|
19
|
-
}
|
|
20
|
-
export declare class BinaryOpScalarProgram implements WebGPUProgram {
|
|
21
|
-
dispatch: [number, number, number];
|
|
22
|
-
dispatchLayout: {
|
|
23
|
-
x: number[];
|
|
24
|
-
};
|
|
25
|
-
outputComponent: number;
|
|
26
|
-
op: BinaryOpType;
|
|
27
|
-
outputShape: number[];
|
|
28
|
-
shaderKey: string;
|
|
29
|
-
size: boolean;
|
|
30
|
-
variableNames: string[];
|
|
31
|
-
workgroupSize: [number, number, number];
|
|
32
|
-
variableComponents: number[];
|
|
33
|
-
constructor(op: BinaryOpType, aShape: number[]);
|
|
34
|
-
getUserCode(): string;
|
|
35
|
-
}
|