@genai-fi/nanogpt 0.20.0 → 0.20.2
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/dist/BaseTokeniser-DSg9zcYq.js +221 -0
- package/dist/DatasetBuilder-DgURD85T.js +712 -0
- package/dist/Generator.d.ts +82 -0
- package/dist/Generator.js +2 -0
- package/dist/RealDiv-DBu0FQqT.js +362 -0
- package/dist/Reshape-CABOPB9d.js +94 -0
- package/dist/Reshape-DqO3r8BC.js +17 -0
- package/dist/TeachableLLM.d.ts +70 -0
- package/dist/TeachableLLM.js +2 -0
- package/dist/Trainer.d.ts +43 -0
- package/dist/Trainer.js +2 -0
- package/dist/backend.d.ts +2 -0
- package/dist/backend.js +13 -0
- package/dist/backend_util-Cg-roD1p.js +399 -0
- package/dist/binary_op_util-CrYk9LXL.js +103 -0
- package/dist/checks/appendCache.d.ts +1 -0
- package/dist/checks/appendCache.js +55 -0
- package/dist/checks/attentionMask.d.ts +1 -0
- package/dist/checks/attentionMask.js +56 -0
- package/dist/checks/check.d.ts +9 -0
- package/dist/checks/check.js +32 -0
- package/dist/checks/gelu.d.ts +1 -0
- package/dist/checks/gelu.js +46 -0
- package/dist/checks/index.d.ts +26 -0
- package/dist/checks/index.js +28 -0
- package/dist/checks/matMulGelu.d.ts +1 -0
- package/dist/checks/matMulGelu.js +84 -0
- package/dist/checks/normRMS.d.ts +1 -0
- package/dist/checks/normRMS.js +28 -0
- package/dist/checks/normRMSGrad.d.ts +1 -0
- package/dist/checks/normRMSGrad.js +22 -0
- package/dist/checks/packUnpack.d.ts +1 -0
- package/dist/checks/packUnpack.js +46 -0
- package/dist/checks/qkv.d.ts +1 -0
- package/dist/checks/qkv.js +34 -0
- package/dist/checks/rope.d.ts +1 -0
- package/dist/checks/rope.js +30 -0
- package/dist/checks/weights.d.ts +14 -0
- package/dist/checks/weights.js +27 -0
- package/dist/chunk-BPntVaq0.js +23 -0
- package/dist/complex_util-CkazZsaH.js +60 -0
- package/dist/concat_util-CWDZCBlA.js +19 -0
- package/dist/data/docx.d.ts +2 -0
- package/dist/data/docx.js +3046 -0
- package/dist/data/pdf.d.ts +2 -0
- package/dist/data/pdf.js +17 -0
- package/dist/data/textLoader.d.ts +7 -0
- package/dist/data/textLoader.js +613 -0
- package/dist/dist-BewPQWjc.js +7572 -0
- package/dist/dist-DVmq73nz.js +8775 -0
- package/dist/dist-DXwIvKxl.js +896 -0
- package/dist/dist-VEU5mfO0.js +7545 -0
- package/dist/gelu-Bf1HW1RY.js +27 -0
- package/dist/gpgpu_math-DvLcCH6u.js +1612 -0
- package/dist/inference/types.d.ts +16 -0
- package/dist/inference/types.js +0 -0
- package/dist/kernel_funcs_utils-HiXOOx3f.js +229 -0
- package/dist/layers/BaseLayer.d.ts +44 -0
- package/dist/layers/BaseLayer.js +76 -0
- package/dist/layers/CausalSelfAttention.d.ts +39 -0
- package/dist/layers/CausalSelfAttention.js +99 -0
- package/dist/layers/LoRA.d.ts +14 -0
- package/dist/layers/LoRA.js +48 -0
- package/dist/layers/MLP.d.ts +17 -0
- package/dist/layers/MLP.js +34 -0
- package/dist/layers/PositionEmbedding.d.ts +8 -0
- package/dist/layers/PositionEmbedding.js +27 -0
- package/dist/layers/RMSNorm.d.ts +12 -0
- package/dist/layers/RMSNorm.js +20 -0
- package/dist/layers/RoPECache.d.ts +18 -0
- package/dist/layers/RoPECache.js +337 -0
- package/dist/layers/TiedEmbedding.d.ts +13 -0
- package/dist/layers/TiedEmbedding.js +32 -0
- package/dist/layers/TransformerBlock.d.ts +27 -0
- package/dist/layers/TransformerBlock.js +51 -0
- package/dist/layers/WeightStore.d.ts +20 -0
- package/dist/layers/WeightStore.js +69 -0
- package/dist/loader/load.d.ts +6 -0
- package/dist/loader/load.js +2 -0
- package/dist/loader/loadHF.d.ts +8 -0
- package/dist/loader/loadHF.js +2 -0
- package/dist/loader/loadTransformers.d.ts +4 -0
- package/dist/loader/loadTransformers.js +2 -0
- package/dist/loader/loadZipMeta.d.ts +3 -0
- package/dist/loader/loadZipMeta.js +16 -0
- package/dist/loader/newZipLoad.d.ts +3 -0
- package/dist/loader/newZipLoad.js +2 -0
- package/dist/loader/oldZipLoad.d.ts +9 -0
- package/dist/loader/oldZipLoad.js +2 -0
- package/dist/loader/save.d.ts +16 -0
- package/dist/loader/save.js +2 -0
- package/dist/loader/types.d.ts +68 -0
- package/dist/loader/types.js +0 -0
- package/dist/main-D5CbfCiV.js +13500 -0
- package/dist/main.d.ts +50 -0
- package/dist/main.js +16 -0
- package/dist/matMul16-BNfZSnNM.js +81 -0
- package/dist/matMulGelu-CPTntosE.js +162 -0
- package/dist/models/NanoGPTV1.d.ts +16 -0
- package/dist/models/NanoGPTV1.js +2 -0
- package/dist/models/NanoGPTV2.d.ts +16 -0
- package/dist/models/NanoGPTV2.js +2 -0
- package/dist/models/config.d.ts +27 -0
- package/dist/models/config.js +37 -0
- package/dist/models/factory.d.ts +3 -0
- package/dist/models/factory.js +2 -0
- package/dist/models/model.d.ts +44 -0
- package/dist/models/model.js +2 -0
- package/dist/ops/adamAdjust.d.ts +2 -0
- package/dist/ops/adamAdjust.js +18 -0
- package/dist/ops/adamMoments.d.ts +2 -0
- package/dist/ops/adamMoments.js +16 -0
- package/dist/ops/add16.d.ts +2 -0
- package/dist/ops/add16.js +12 -0
- package/dist/ops/appendCache.d.ts +2 -0
- package/dist/ops/appendCache.js +25 -0
- package/dist/ops/attentionMask.d.ts +2 -0
- package/dist/ops/attentionMask.js +16 -0
- package/dist/ops/concat16.d.ts +2 -0
- package/dist/ops/concat16.js +8 -0
- package/dist/ops/cpu/adamAdjust.d.ts +1 -0
- package/dist/ops/cpu/adamAdjust.js +16 -0
- package/dist/ops/cpu/adamMoments.d.ts +1 -0
- package/dist/ops/cpu/adamMoments.js +16 -0
- package/dist/ops/cpu/appendCache.d.ts +1 -0
- package/dist/ops/cpu/appendCache.js +65 -0
- package/dist/ops/cpu/attentionMask.d.ts +1 -0
- package/dist/ops/cpu/attentionMask.js +16 -0
- package/dist/ops/cpu/fusedSoftmax.d.ts +9 -0
- package/dist/ops/cpu/fusedSoftmax.js +22 -0
- package/dist/ops/cpu/gatherSub.d.ts +1 -0
- package/dist/ops/cpu/gatherSub.js +12 -0
- package/dist/ops/cpu/gelu.d.ts +1 -0
- package/dist/ops/cpu/gelu.js +36 -0
- package/dist/ops/cpu/matMul16.d.ts +1 -0
- package/dist/ops/cpu/matMul16.js +14 -0
- package/dist/ops/cpu/matMulGelu.d.ts +1 -0
- package/dist/ops/cpu/matMulGelu.js +41 -0
- package/dist/ops/cpu/matMulMul.d.ts +1 -0
- package/dist/ops/cpu/matMulMul.js +20 -0
- package/dist/ops/cpu/mulDropout.d.ts +1 -0
- package/dist/ops/cpu/mulDropout.js +20 -0
- package/dist/ops/cpu/normRMS.d.ts +1 -0
- package/dist/ops/cpu/normRMS.js +35 -0
- package/dist/ops/cpu/qkv.d.ts +5 -0
- package/dist/ops/cpu/qkv.js +73 -0
- package/dist/ops/cpu/rope.d.ts +6 -0
- package/dist/ops/cpu/rope.js +81 -0
- package/dist/ops/cpu/scatterSub.d.ts +1 -0
- package/dist/ops/cpu/scatterSub.js +12 -0
- package/dist/ops/dot16.d.ts +2 -0
- package/dist/ops/dot16.js +29 -0
- package/dist/ops/dropout.d.ts +2 -0
- package/dist/ops/dropout.js +11 -0
- package/dist/ops/dropout16.d.ts +2 -0
- package/dist/ops/dropout16.js +22 -0
- package/dist/ops/gatherSub.d.ts +2 -0
- package/dist/ops/gatherSub.js +13 -0
- package/dist/ops/gelu.d.ts +3 -0
- package/dist/ops/gelu.js +2 -0
- package/dist/ops/globalNorm.d.ts +2 -0
- package/dist/ops/globalNorm.js +19 -0
- package/dist/ops/grads/add16.d.ts +1 -0
- package/dist/ops/grads/add16.js +27 -0
- package/dist/ops/grads/attentionMask.d.ts +1 -0
- package/dist/ops/grads/attentionMask.js +26 -0
- package/dist/ops/grads/dropout16.d.ts +1 -0
- package/dist/ops/grads/dropout16.js +1 -0
- package/dist/ops/grads/gelu.d.ts +2 -0
- package/dist/ops/grads/gelu.js +2 -0
- package/dist/ops/grads/matMul16.d.ts +2 -0
- package/dist/ops/grads/matMul16.js +2 -0
- package/dist/ops/grads/matMulGelu.d.ts +1 -0
- package/dist/ops/grads/matMulGelu.js +22 -0
- package/dist/ops/grads/mul16.d.ts +1 -0
- package/dist/ops/grads/mul16.js +1 -0
- package/dist/ops/grads/normRMS.d.ts +3 -0
- package/dist/ops/grads/normRMS.js +37 -0
- package/dist/ops/grads/pack16.d.ts +2 -0
- package/dist/ops/grads/pack16.js +2 -0
- package/dist/ops/grads/qkv.d.ts +3 -0
- package/dist/ops/grads/qkv.js +46 -0
- package/dist/ops/grads/rope.d.ts +2 -0
- package/dist/ops/grads/rope.js +2 -0
- package/dist/ops/grads/softmax16.d.ts +2 -0
- package/dist/ops/grads/softmax16.js +23 -0
- package/dist/ops/grads/unpack16.d.ts +2 -0
- package/dist/ops/grads/unpack16.js +2 -0
- package/dist/ops/grads/utils.d.ts +4 -0
- package/dist/ops/grads/utils.js +12 -0
- package/dist/ops/log.d.ts +0 -0
- package/dist/ops/log.js +1 -0
- package/dist/ops/matMul16.d.ts +15 -0
- package/dist/ops/matMul16.js +2 -0
- package/dist/ops/matMulGelu.d.ts +3 -0
- package/dist/ops/matMulGelu.js +20 -0
- package/dist/ops/matMulMul.d.ts +2 -0
- package/dist/ops/matMulMul.js +16 -0
- package/dist/ops/mul16.d.ts +2 -0
- package/dist/ops/mul16.js +43 -0
- package/dist/ops/mulDrop.d.ts +2 -0
- package/dist/ops/mulDrop.js +15 -0
- package/dist/ops/normRMS.d.ts +2 -0
- package/dist/ops/normRMS.js +22 -0
- package/dist/ops/pack16.d.ts +2 -0
- package/dist/ops/pack16.js +2 -0
- package/dist/ops/qkv.d.ts +2 -0
- package/dist/ops/qkv.js +16 -0
- package/dist/ops/reshape16.d.ts +2 -0
- package/dist/ops/reshape16.js +33 -0
- package/dist/ops/rope.d.ts +3 -0
- package/dist/ops/rope.js +2 -0
- package/dist/ops/scatterSub.d.ts +2 -0
- package/dist/ops/scatterSub.js +13 -0
- package/dist/ops/slice16.d.ts +2 -0
- package/dist/ops/slice16.js +11 -0
- package/dist/ops/softmax16.d.ts +2 -0
- package/dist/ops/softmax16.js +9 -0
- package/dist/ops/sub16.d.ts +2 -0
- package/dist/ops/sub16.js +11 -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 +32 -0
- package/dist/ops/unpack16.d.ts +2 -0
- package/dist/ops/unpack16.js +2 -0
- package/dist/ops/webgl/adamAdjust.d.ts +1 -0
- package/dist/ops/webgl/adamAdjust.js +82 -0
- package/dist/ops/webgl/adamMoments.d.ts +1 -0
- package/dist/ops/webgl/adamMoments.js +44 -0
- package/dist/ops/webgl/appendCache.d.ts +1 -0
- package/dist/ops/webgl/appendCache.js +53 -0
- package/dist/ops/webgl/attentionMask.d.ts +1 -0
- package/dist/ops/webgl/attentionMask.js +64 -0
- package/dist/ops/webgl/dropout16.d.ts +1 -0
- package/dist/ops/webgl/dropout16.js +12 -0
- package/dist/ops/webgl/fusedSoftmax.d.ts +11 -0
- package/dist/ops/webgl/fusedSoftmax.js +70 -0
- package/dist/ops/webgl/gatherSub.d.ts +1 -0
- package/dist/ops/webgl/gatherSub.js +28 -0
- package/dist/ops/webgl/gelu.d.ts +2 -0
- package/dist/ops/webgl/gelu.js +48 -0
- package/dist/ops/webgl/log.d.ts +17 -0
- package/dist/ops/webgl/log.js +14 -0
- package/dist/ops/webgl/matMul16.d.ts +1 -0
- package/dist/ops/webgl/matMul16.js +37 -0
- package/dist/ops/webgl/matMulGelu.d.ts +21 -0
- package/dist/ops/webgl/matMulGelu.js +2 -0
- package/dist/ops/webgl/matMulMul.d.ts +14 -0
- package/dist/ops/webgl/matMulMul.js +24 -0
- package/dist/ops/webgl/mulDropout.d.ts +1 -0
- package/dist/ops/webgl/mulDropout.js +32 -0
- package/dist/ops/webgl/normRMS.d.ts +1 -0
- package/dist/ops/webgl/normRMS.js +114 -0
- package/dist/ops/webgl/qkv.d.ts +1 -0
- package/dist/ops/webgl/qkv.js +54 -0
- package/dist/ops/webgl/rope.d.ts +1 -0
- package/dist/ops/webgl/rope.js +72 -0
- package/dist/ops/webgl/scatterSub.d.ts +1 -0
- package/dist/ops/webgl/scatterSub.js +28 -0
- package/dist/ops/webgpu/adamAdjust.d.ts +1 -0
- package/dist/ops/webgpu/adamAdjust.js +77 -0
- package/dist/ops/webgpu/adamMoments.d.ts +1 -0
- package/dist/ops/webgpu/adamMoments.js +76 -0
- package/dist/ops/webgpu/add16.d.ts +1 -0
- package/dist/ops/webgpu/add16.js +14 -0
- package/dist/ops/webgpu/appendCache.d.ts +1 -0
- package/dist/ops/webgpu/appendCache.js +130 -0
- package/dist/ops/webgpu/attentionMask.d.ts +1 -0
- package/dist/ops/webgpu/attentionMask.js +42 -0
- package/dist/ops/webgpu/attentionMask32_program.d.ts +19 -0
- package/dist/ops/webgpu/attentionMask32_program.js +62 -0
- package/dist/ops/webgpu/clipScale.d.ts +1 -0
- package/dist/ops/webgpu/clipScale.js +45 -0
- package/dist/ops/webgpu/concat16.d.ts +19 -0
- package/dist/ops/webgpu/concat16.js +111 -0
- package/dist/ops/webgpu/dropout16.d.ts +1 -0
- package/dist/ops/webgpu/dropout16.js +59 -0
- package/dist/ops/webgpu/gatherSub.d.ts +1 -0
- package/dist/ops/webgpu/gatherSub.js +52 -0
- package/dist/ops/webgpu/gelu.d.ts +14 -0
- package/dist/ops/webgpu/gelu.js +147 -0
- package/dist/ops/webgpu/index.d.ts +0 -0
- package/dist/ops/webgpu/index.js +26 -0
- package/dist/ops/webgpu/matMul16.d.ts +1 -0
- package/dist/ops/webgpu/matMul16.js +70 -0
- package/dist/ops/webgpu/matMul16_program.d.ts +42 -0
- package/dist/ops/webgpu/matMul16_program.js +303 -0
- package/dist/ops/webgpu/mul16.d.ts +1 -0
- package/dist/ops/webgpu/mul16.js +14 -0
- package/dist/ops/webgpu/norm2.d.ts +1 -0
- package/dist/ops/webgpu/norm2.js +46 -0
- package/dist/ops/webgpu/normRMS.d.ts +1 -0
- package/dist/ops/webgpu/normRMS.js +26 -0
- package/dist/ops/webgpu/normRMS16_program.d.ts +10 -0
- package/dist/ops/webgpu/normRMS16_program.js +28 -0
- package/dist/ops/webgpu/normRMS32_program.d.ts +10 -0
- package/dist/ops/webgpu/normRMS32_program.js +28 -0
- package/dist/ops/webgpu/normRMSGrad.d.ts +1 -0
- package/dist/ops/webgpu/normRMSGrad.js +225 -0
- package/dist/ops/webgpu/pack16.d.ts +1 -0
- package/dist/ops/webgpu/pack16.js +21 -0
- package/dist/ops/webgpu/pack16_program.d.ts +19 -0
- package/dist/ops/webgpu/pack16_program.js +93 -0
- package/dist/ops/webgpu/qkv.d.ts +1 -0
- package/dist/ops/webgpu/qkv.js +64 -0
- package/dist/ops/webgpu/rope.d.ts +1 -0
- package/dist/ops/webgpu/rope.js +163 -0
- package/dist/ops/webgpu/scatterSub.d.ts +1 -0
- package/dist/ops/webgpu/scatterSub.js +53 -0
- package/dist/ops/webgpu/slice16.d.ts +7 -0
- package/dist/ops/webgpu/slice16.js +74 -0
- package/dist/ops/webgpu/softmax16.d.ts +17 -0
- package/dist/ops/webgpu/softmax16.js +18 -0
- package/dist/ops/webgpu/softmax16_program.d.ts +13 -0
- package/dist/ops/webgpu/softmax16_program.js +89 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.d.ts +17 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.js +70 -0
- package/dist/ops/webgpu/softmax16grad.d.ts +1 -0
- package/dist/ops/webgpu/softmax16grad.js +31 -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 +29 -0
- package/dist/ops/webgpu/transpose16.d.ts +1 -0
- package/dist/ops/webgpu/transpose16.js +37 -0
- package/dist/ops/webgpu/transpose16_program.d.ts +16 -0
- package/dist/ops/webgpu/transpose16_program.js +51 -0
- package/dist/ops/webgpu/transpose16_shared_program.d.ts +15 -0
- package/dist/ops/webgpu/transpose16_shared_program.js +79 -0
- package/dist/ops/webgpu/unpack16.d.ts +1 -0
- package/dist/ops/webgpu/unpack16.js +60 -0
- package/dist/ops/webgpu/utils/binary_op.d.ts +35 -0
- package/dist/ops/webgpu/utils/binary_op.js +141 -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 +43 -0
- package/dist/ops/webgpu/utils/reductions.js +263 -0
- package/dist/pack16-Ck-spx_F.js +39 -0
- package/dist/patches/webgpu_backend.d.ts +18 -0
- package/dist/patches/webgpu_backend.js +43 -0
- package/dist/patches/webgpu_base.d.ts +21 -0
- package/dist/patches/webgpu_base.js +22 -0
- package/dist/patches/webgpu_program.d.ts +36 -0
- package/dist/patches/webgpu_program.js +293 -0
- package/dist/pdf-UoDqCYzz.js +16726 -0
- package/dist/picomatch-3tUnMMbd.js +1063 -0
- package/dist/rope-CbeGlsV8.js +25 -0
- package/dist/selu_util-zkAx5doH.js +24 -0
- package/dist/shared-D1coEFea.js +1314 -0
- package/dist/shared-DOgWaqvL.js +5 -0
- package/dist/slice_util-Dgb3ANWI.js +208 -0
- package/dist/tfjs_backend-BjuQ5FqB.js +614 -0
- package/dist/tokeniser/BaseTokeniser.d.ts +33 -0
- package/dist/tokeniser/BaseTokeniser.js +2 -0
- package/dist/tokeniser/CharTokeniser.d.ts +24 -0
- package/dist/tokeniser/CharTokeniser.js +92 -0
- package/dist/tokeniser/bpe.d.ts +28 -0
- package/dist/tokeniser/bpe.js +170 -0
- package/dist/tokeniser/messages.d.ts +61 -0
- package/dist/tokeniser/messages.js +0 -0
- package/dist/tokeniser/type.d.ts +34 -0
- package/dist/tokeniser/type.js +0 -0
- package/dist/training/AdamW.d.ts +36 -0
- package/dist/training/AdamW.js +128 -0
- package/dist/training/BasicTrainer.d.ts +63 -0
- package/dist/training/BasicTrainer.js +265 -0
- package/dist/training/DatasetBuilder.d.ts +26 -0
- package/dist/training/DatasetBuilder.js +2 -0
- package/dist/training/Evaluator.d.ts +19 -0
- package/dist/training/Evaluator.js +48 -0
- package/dist/training/LRScheduler.d.ts +12 -0
- package/dist/training/LRScheduler.js +38 -0
- package/dist/training/PreTrainer.d.ts +11 -0
- package/dist/training/PreTrainer.js +22 -0
- package/dist/training/SFTTrainer.d.ts +12 -0
- package/dist/training/SFTTrainer.js +24 -0
- package/dist/training/loss.d.ts +3 -0
- package/dist/training/loss.js +19 -0
- package/dist/training/orthoGrad.d.ts +2 -0
- package/dist/training/orthoGrad.js +10 -0
- package/dist/training/sparseCrossEntropy.d.ts +7 -0
- package/dist/training/sparseCrossEntropy.js +47 -0
- package/dist/training/tasks/ConversationTask.d.ts +18 -0
- package/dist/training/tasks/ConversationTask.js +38 -0
- package/dist/training/tasks/PretrainingTask.d.ts +17 -0
- package/dist/training/tasks/PretrainingTask.js +42 -0
- package/dist/training/tasks/StartSentenceTask.d.ts +18 -0
- package/dist/training/tasks/StartSentenceTask.js +45 -0
- package/dist/training/tasks/Task.d.ts +22 -0
- package/dist/training/tasks/Task.js +55 -0
- package/dist/training/tasks/splitter.d.ts +5 -0
- package/dist/training/tasks/splitter.js +18 -0
- package/dist/training/types.d.ts +78 -0
- package/dist/training/types.js +0 -0
- package/dist/training/validation.d.ts +17 -0
- package/dist/training/validation.js +2 -0
- package/dist/utilities/arrayClose.d.ts +1 -0
- package/dist/utilities/arrayClose.js +16 -0
- package/dist/utilities/datasetID.d.ts +2 -0
- package/dist/utilities/datasetID.js +18 -0
- package/dist/utilities/dummy.d.ts +9 -0
- package/dist/utilities/dummy.js +36 -0
- package/dist/utilities/multinomialCPU.d.ts +2 -0
- package/dist/utilities/multinomialCPU.js +9 -0
- package/dist/utilities/naming.d.ts +4 -0
- package/dist/utilities/naming.js +0 -0
- package/dist/utilities/packed.d.ts +4 -0
- package/dist/utilities/packed.js +13 -0
- package/dist/utilities/parameters.d.ts +11 -0
- package/dist/utilities/parameters.js +38 -0
- package/dist/utilities/performance.d.ts +2 -0
- package/dist/utilities/performance.js +16 -0
- package/dist/utilities/profile.d.ts +17 -0
- package/dist/utilities/profile.js +33 -0
- package/dist/utilities/safetensors.d.ts +3 -0
- package/dist/utilities/safetensors.js +53 -0
- package/dist/utilities/sentences.d.ts +5 -0
- package/dist/utilities/sentences.js +32 -0
- package/dist/utilities/tokenParse.d.ts +1 -0
- package/dist/utilities/tokenParse.js +17 -0
- package/dist/utilities/topP.d.ts +1 -0
- package/dist/utilities/topP.js +12 -0
- package/dist/utilities/waitForModel.d.ts +2 -0
- package/dist/utilities/waitForModel.js +12 -0
- package/dist/utilities/weights.d.ts +12 -0
- package/dist/utilities/weights.js +40 -0
- package/dist/utilities/yielder.d.ts +1 -0
- package/dist/utilities/yielder.js +7 -0
- package/dist/webgpu-Dt7BMzWz.js +525 -0
- package/dist/webgpu_program-WOyIVMlZ.js +392 -0
- package/dist/webgpu_util-B_F3SShA.js +106 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { I as e, Wr as t, _r as n, mn as r, un as i } from "../dist-BewPQWjc.js";
|
|
2
|
+
//#region lib/utilities/sentences.ts
|
|
3
|
+
var a = 16;
|
|
4
|
+
function o(e, n) {
|
|
5
|
+
if (!n) return e.mean(1);
|
|
6
|
+
let a = i(n, 2), o = t(e, a), s = r(o, 1), c = r(n, 1, !0), l = s.div(c.maximum(1e-9));
|
|
7
|
+
return a.dispose(), o.dispose(), s.dispose(), c.dispose(), l;
|
|
8
|
+
}
|
|
9
|
+
function s(t, r, i = a) {
|
|
10
|
+
let s = t.tokeniser, c = t.config.blockSize, l = null, u = 0;
|
|
11
|
+
for (; u < r.length;) {
|
|
12
|
+
let d = r.slice(u, u + a).map((e) => s.encode(e)), f = [], p = [];
|
|
13
|
+
for (let e of d) e.length > c ? (f.push(e.slice(e.length - c, e.length)), p.push(Array(c).fill(1))) : e.length < c ? (f.push(e.concat(Array(c - e.length).fill(0))), p.push(Array(e.length).fill(1).concat(Array(c - e.length).fill(0)))) : (f.push(e), p.push(Array(c).fill(1)));
|
|
14
|
+
let m = e(f, [f.length, c], "int32"), h = e(p, [p.length, c], "float32"), g = t.model.forward({
|
|
15
|
+
skipLogits: !0,
|
|
16
|
+
training: !1
|
|
17
|
+
}, m), _ = o(g, h);
|
|
18
|
+
if (h.dispose(), g.dispose(), l === null) l = _;
|
|
19
|
+
else {
|
|
20
|
+
let e = l;
|
|
21
|
+
l = n([l, _], 0), e.dispose(), _.dispose();
|
|
22
|
+
}
|
|
23
|
+
u += i;
|
|
24
|
+
}
|
|
25
|
+
return l;
|
|
26
|
+
}
|
|
27
|
+
async function c(e, t, n = a) {
|
|
28
|
+
let r = await s(e, t, n), i = await r.array();
|
|
29
|
+
return r.dispose(), i;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { o as meanPooling, c as sentenceEmbeddings, s as sentenceEmbeddingsTensor };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function parseTokens(text: string): string[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region lib/utilities/tokenParse.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = Array.from(e), n = [], r = /(\p{P}|\p{S}|\s)/gu, i = "";
|
|
4
|
+
for (let e = 0; e < t.length; e++) {
|
|
5
|
+
let a = t[e];
|
|
6
|
+
if (a === " ") (t[e + 1] ?? "") === " " ? i += a : (n.push(i), i = a);
|
|
7
|
+
else if (a.match(r)) {
|
|
8
|
+
n.push(i);
|
|
9
|
+
let r = a;
|
|
10
|
+
for (; e + 1 < t.length && t[e + 1] === a;) r += t[e + 1], e++;
|
|
11
|
+
n.push(r), i = "";
|
|
12
|
+
} else i += a;
|
|
13
|
+
}
|
|
14
|
+
return i.length > 0 && n.push(i), n.filter((e) => e.length > 0);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { e as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function topP(probs: number[][], tP: number): number[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region lib/utilities/topP.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
let n = e[0].map((e, t) => ({
|
|
4
|
+
prob: e,
|
|
5
|
+
index: t
|
|
6
|
+
})).sort((e, t) => t.prob - e.prob), r = 0, i = Array(n.length).fill(0);
|
|
7
|
+
for (let e of n) if (r += e.prob, i[e.index] = e.prob, r >= t) break;
|
|
8
|
+
let a = i.reduce((e, t) => e + t, 0);
|
|
9
|
+
return i.map((e) => e / a);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { e as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tensor } from '@tensorflow/tfjs-core';
|
|
2
|
+
export interface ITensorSpec {
|
|
3
|
+
shape: number[];
|
|
4
|
+
min?: number;
|
|
5
|
+
scale?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface IWeightManifest {
|
|
8
|
+
spec: ITensorSpec[];
|
|
9
|
+
data: Float32Array;
|
|
10
|
+
}
|
|
11
|
+
export declare function exportWeights(weights: Tensor[]): Promise<IWeightManifest>;
|
|
12
|
+
export declare function importWeights(manifest: IWeightManifest): Promise<Tensor[]>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { fi as e } from "../dist-BewPQWjc.js";
|
|
2
|
+
//#region lib/utilities/weights.ts
|
|
3
|
+
function t(e) {
|
|
4
|
+
let t = e.reduce((e, t) => e + t.length, 0), n = new Float32Array(t), r = 0;
|
|
5
|
+
for (let t of e) n.set(t, r), r += t.length;
|
|
6
|
+
return n;
|
|
7
|
+
}
|
|
8
|
+
async function n(e) {
|
|
9
|
+
let n = {
|
|
10
|
+
spec: [],
|
|
11
|
+
data: new Float32Array()
|
|
12
|
+
}, r = [];
|
|
13
|
+
for (let t of e) {
|
|
14
|
+
if (!t || !Array.isArray(t.shape) || t.shape.length === 0) {
|
|
15
|
+
console.warn("Skipping weight with invalid shape:", t);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
let e = t.min(), i = t.max(), a = (await e.data())[0], o = (await i.data())[0] - a;
|
|
19
|
+
n.spec.push({
|
|
20
|
+
shape: t.shape,
|
|
21
|
+
min: a,
|
|
22
|
+
scale: o
|
|
23
|
+
}), e.dispose(), i.dispose();
|
|
24
|
+
let s = await t.data();
|
|
25
|
+
r.push(s);
|
|
26
|
+
}
|
|
27
|
+
return n.data = t(r), n;
|
|
28
|
+
}
|
|
29
|
+
async function r(t) {
|
|
30
|
+
let n = [], r = 0;
|
|
31
|
+
for (let i of t.spec) {
|
|
32
|
+
let a = i.shape.reduce((e, t) => e * t, 1), o = t.data.slice(r, r + a);
|
|
33
|
+
r += a;
|
|
34
|
+
let s = e(o, i.shape, "float32");
|
|
35
|
+
n.push(s);
|
|
36
|
+
}
|
|
37
|
+
return n;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { n as exportWeights, r as importWeights };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function yieldIfNeeded(lastYield: number, cb?: (vocab: number) => void, param?: number): Promise<number>;
|
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import { Ai as e, Ms as t, Oi as n, Ps as r, Rs as i, Vs as a, Xr as o, Ys as s, fc as c, ii as l, ki as u, lc as d, oc as f, pc as p, zs as m } from "./dist-BewPQWjc.js";
|
|
2
|
+
import { s as h } from "./complex_util-CkazZsaH.js";
|
|
3
|
+
import { l as g, n as _, t as v } from "./webgpu_program-WOyIVMlZ.js";
|
|
4
|
+
import { l as y, t as b } from "./webgpu_util-B_F3SShA.js";
|
|
5
|
+
//#region node_modules/@tensorflow/tfjs-backend-webgpu/dist/flags_webgpu.js
|
|
6
|
+
var x = t();
|
|
7
|
+
x.registerFlag("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE", () => 15), x.registerFlag("WEBGPU_CPU_FORWARD", () => !0), x.registerFlag("WEBGPU_MATMUL_PROGRAM_TYPE", () => -1), x.registerFlag("WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE", () => !0), x.registerFlag("WEBGPU_USE_LOW_POWER_GPU", () => !1), x.registerFlag("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD", () => 1e3), x.registerFlag("WEBGPU_USE_PROFILE_TOOL", () => !1), x.registerFlag("WEBGPU_IMPORT_EXTERNAL_TEXTURE", () => !0), x.registerFlag("WEBGPU_USE_NAIVE_CONV2D_DEBUG", () => !1), x.registerFlag("WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL", () => -1), x.registerFlag("WEBGPU_CONV_SEPARATE_IM2COL_SHADER", () => !1), x.registerFlag("WEBGPU_PRINT_SHADER", () => ""), x.registerFlag("WEBGPU_ENGINE_COMPILE_ONLY", () => !1);
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region node_modules/@tensorflow/tfjs-backend-webgpu/dist/adapter_info.js
|
|
10
|
+
var S = class {
|
|
11
|
+
constructor(e) {
|
|
12
|
+
e && (this.vendor = e.vendor, this.architecture = e.architecture, this.intelGPUGeneration = this.getIntelGPUGeneration());
|
|
13
|
+
}
|
|
14
|
+
getIntelGPUGeneration() {
|
|
15
|
+
if (this.isIntel()) {
|
|
16
|
+
if (this.architecture.startsWith("gen")) return Number(this.architecture.match(/\d+/));
|
|
17
|
+
if (this.architecture.startsWith("xe")) return 12;
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
isIntel() {
|
|
22
|
+
return this.vendor === "intel";
|
|
23
|
+
}
|
|
24
|
+
}, C = class {
|
|
25
|
+
constructor(e) {
|
|
26
|
+
this.device = e, this.numUsedBuffers = 0, this.numFreeBuffers = 0, this.freeBuffers = /* @__PURE__ */ new Map(), this.usedBuffers = /* @__PURE__ */ new Map(), this.numBytesUsed = 0, this.numBytesAllocated = 0;
|
|
27
|
+
}
|
|
28
|
+
acquireBuffer(e, t, n = !1, r = !0) {
|
|
29
|
+
let i, a = w(e, t);
|
|
30
|
+
return r ? (this.freeBuffers.has(a) || this.freeBuffers.set(a, []), this.freeBuffers.get(a).length > 0 ? (i = this.freeBuffers.get(a).pop(), this.numFreeBuffers--) : (i = this.device.createBuffer({
|
|
31
|
+
size: e,
|
|
32
|
+
usage: t,
|
|
33
|
+
mappedAtCreation: n
|
|
34
|
+
}), this.numBytesAllocated += e)) : (i = this.device.createBuffer({
|
|
35
|
+
size: e,
|
|
36
|
+
usage: t,
|
|
37
|
+
mappedAtCreation: n
|
|
38
|
+
}), this.numBytesAllocated += e), this.usedBuffers.has(a) || this.usedBuffers.set(a, []), this.usedBuffers.get(a).push(i), this.numUsedBuffers++, this.numBytesUsed += e, i;
|
|
39
|
+
}
|
|
40
|
+
releaseBuffer(e, t = !0) {
|
|
41
|
+
if (this.freeBuffers.size === 0) return;
|
|
42
|
+
let n = e.size, r = e.usage, i = w(n, r), a = this.usedBuffers.get(i), o = a.indexOf(e);
|
|
43
|
+
if (o < 0) throw Error("Cannot find the buffer in buffer manager");
|
|
44
|
+
a[o] = a[a.length - 1], a.pop(), this.numUsedBuffers--, this.numBytesUsed -= n, t ? (this.freeBuffers.get(i).push(e), this.numFreeBuffers++) : (e.destroy(), this.numBytesAllocated -= n);
|
|
45
|
+
}
|
|
46
|
+
getNumUsedBuffers() {
|
|
47
|
+
return this.numUsedBuffers;
|
|
48
|
+
}
|
|
49
|
+
getNumFreeBuffers() {
|
|
50
|
+
return this.numFreeBuffers;
|
|
51
|
+
}
|
|
52
|
+
dispose() {
|
|
53
|
+
this.freeBuffers.forEach((e, t) => {
|
|
54
|
+
e.forEach((e) => {
|
|
55
|
+
e.destroy();
|
|
56
|
+
});
|
|
57
|
+
}), this.usedBuffers.forEach((e, t) => {
|
|
58
|
+
e.forEach((e) => {
|
|
59
|
+
e.destroy();
|
|
60
|
+
});
|
|
61
|
+
}), this.freeBuffers = /* @__PURE__ */ new Map(), this.usedBuffers = /* @__PURE__ */ new Map(), this.numUsedBuffers = 0, this.numFreeBuffers = 0, this.numBytesUsed = 0, this.numBytesAllocated = 0;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
function w(e, t) {
|
|
65
|
+
return `${e}_${t}`;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region node_modules/@tensorflow/tfjs-backend-webgpu/dist/texture_manager.js
|
|
69
|
+
var T = class {
|
|
70
|
+
constructor(e) {
|
|
71
|
+
this.device = e, this.numUsedTextures = 0, this.numFreeTextures = 0, this.freeTextures = /* @__PURE__ */ new Map(), this.usedTextures = /* @__PURE__ */ new Map(), this.numBytesUsed = 0, this.numBytesAllocated = 0;
|
|
72
|
+
}
|
|
73
|
+
acquireTexture(e, t, n, r) {
|
|
74
|
+
let i = D(n), a = e * t * i, o = E(e, t, n, r);
|
|
75
|
+
if (this.freeTextures.has(o) || this.freeTextures.set(o, []), this.usedTextures.has(o) || this.usedTextures.set(o, []), this.numBytesUsed += a, this.numUsedTextures++, this.freeTextures.get(o).length > 0) {
|
|
76
|
+
this.numFreeTextures--;
|
|
77
|
+
let e = this.freeTextures.get(o).shift();
|
|
78
|
+
return this.usedTextures.get(o).push(e), e;
|
|
79
|
+
}
|
|
80
|
+
this.numBytesAllocated += a;
|
|
81
|
+
let s = this.device.createTexture({
|
|
82
|
+
size: [e, t],
|
|
83
|
+
format: n,
|
|
84
|
+
usage: r
|
|
85
|
+
});
|
|
86
|
+
return this.usedTextures.get(o).push(s), s;
|
|
87
|
+
}
|
|
88
|
+
releaseTexture(e) {
|
|
89
|
+
if (this.freeTextures.size === 0) return;
|
|
90
|
+
let t = e.width, n = e.height, r = e.format, i = e.usage, a = E(t, n, r, i);
|
|
91
|
+
this.freeTextures.has(a) || this.freeTextures.set(a, []), this.freeTextures.get(a).push(e), this.numFreeTextures++, this.numUsedTextures--;
|
|
92
|
+
let o = this.usedTextures.get(a), s = o.indexOf(e);
|
|
93
|
+
if (s < 0) throw Error("Cannot release a texture that was never provided by this texture manager");
|
|
94
|
+
o.splice(s, 1);
|
|
95
|
+
let c = D(r), l = t * n * c;
|
|
96
|
+
this.numBytesUsed -= l;
|
|
97
|
+
}
|
|
98
|
+
getNumUsedTextures() {
|
|
99
|
+
return this.numUsedTextures;
|
|
100
|
+
}
|
|
101
|
+
getNumFreeTextures() {
|
|
102
|
+
return this.numFreeTextures;
|
|
103
|
+
}
|
|
104
|
+
dispose() {
|
|
105
|
+
this.freeTextures.forEach((e, t) => {
|
|
106
|
+
e.forEach((e) => {
|
|
107
|
+
e.destroy();
|
|
108
|
+
});
|
|
109
|
+
}), this.usedTextures.forEach((e, t) => {
|
|
110
|
+
e.forEach((e) => {
|
|
111
|
+
e.destroy();
|
|
112
|
+
});
|
|
113
|
+
}), this.freeTextures = /* @__PURE__ */ new Map(), this.usedTextures = /* @__PURE__ */ new Map(), this.numUsedTextures = 0, this.numFreeTextures = 0, this.numBytesUsed = 0, this.numBytesAllocated = 0;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function E(e, t, n, r) {
|
|
117
|
+
return `${e}_${t}_${n}_${r}`;
|
|
118
|
+
}
|
|
119
|
+
function D(e) {
|
|
120
|
+
if (e === "rgba8unorm") return 16;
|
|
121
|
+
throw Error(`${e} is not supported!`);
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region node_modules/@tensorflow/tfjs-backend-webgpu/dist/backend_webgpu.js
|
|
125
|
+
var O = t().getNumber("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD"), k = (e, t) => {
|
|
126
|
+
let n = e.limits.maxComputeWorkgroupsPerDimension, i = t.dispatchLayout, a = t.dispatch;
|
|
127
|
+
if (a.every((e) => e <= n)) return a;
|
|
128
|
+
r(a[0] > n && i.y === void 0 && i.z === void 0, () => "Dispatch size exceeds WebGPU limits in Y or Z dimension.");
|
|
129
|
+
let o = Math.ceil(Math.sqrt(a[0]));
|
|
130
|
+
return o > n ? (o = Math.ceil(Math.cbrt(a[0])), r(o <= n, () => "Total dispatch size exceeds WebGPU maximum."), [
|
|
131
|
+
o,
|
|
132
|
+
o,
|
|
133
|
+
o
|
|
134
|
+
]) : [
|
|
135
|
+
o,
|
|
136
|
+
o,
|
|
137
|
+
1
|
|
138
|
+
];
|
|
139
|
+
}, A = class x extends p {
|
|
140
|
+
nextDataId() {
|
|
141
|
+
return x.nextDataId++;
|
|
142
|
+
}
|
|
143
|
+
constructor(e, n) {
|
|
144
|
+
if (super(), this.commandQueueOwnedIds = /* @__PURE__ */ new WeakSet(), this.dispatchCountInPass = 0, this.disposed = !1, this.downloadWaitMs = 0, this.tensorDataPendingDisposal = [], this.queryResolveBuffer = null, this.querySet = null, this.querySetCount = 2, this.stagingPendingDisposal = [], this.uniformPendingDisposal = [], this.uploadWaitMs = 0, this.hasReadSyncWarned = !1, this.hasTimestampQueryWarned = !1, !y()) throw Error("WebGPU is not supported on this device");
|
|
145
|
+
this.pipelineCache = {}, this.device = e, this.queue = e.queue, this.commandEncoder = null, this.computePassEncoder = null, this.adapterInfo = new S(n), this.supportTimestampQuery = this.device.features.has("timestamp-query"), this.thresholdToIncreaseWorkgroups = this.adapterInfo.intelGPUGeneration >= 12 ? 16 : 8, this.bufferManager = new C(this.device), this.textureManager = new T(this.device), this.tensorMap = new c(this, l()), t().getBool("WEBGPU_USE_PROFILE_TOOL") && (this.dummyCanvas = document.createElement("canvas"), this.dummyCanvas.width = 1, this.dummyCanvas.height = 1, this.dummyContext = this.dummyCanvas.getContext("webgpu"), this.dummyContext.configure({
|
|
146
|
+
device: e,
|
|
147
|
+
format: "bgra8unorm"
|
|
148
|
+
}), document.body.appendChild(this.dummyCanvas));
|
|
149
|
+
}
|
|
150
|
+
floatPrecision() {
|
|
151
|
+
return 32;
|
|
152
|
+
}
|
|
153
|
+
disposeData(e, t = !1) {
|
|
154
|
+
if (!this.tensorMap.has(e)) return !0;
|
|
155
|
+
let n = this.tensorMap.get(e);
|
|
156
|
+
return t ? n.refCount = 0 : n.refCount--, n.refCount > 0 ? !1 : (n.complexTensorInfos != null && (this.disposeData(n.complexTensorInfos.real.dataId), this.disposeData(n.complexTensorInfos.imag.dataId)), this.commandQueueOwnedIds.has(e) ? (this.tensorDataPendingDisposal.push(e), !0) : (this.releaseResource(e), this.tensorMap.delete(e), !0));
|
|
157
|
+
}
|
|
158
|
+
memory() {
|
|
159
|
+
return {
|
|
160
|
+
numBytesInGPU: this.bufferManager.numBytesUsed,
|
|
161
|
+
numBytesAllocatedInGPU: this.bufferManager.numBytesAllocated,
|
|
162
|
+
unreliable: !1
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
releaseResource(e) {
|
|
166
|
+
let t = this.tensorMap.get(e);
|
|
167
|
+
if (!(!t || !t.resource)) {
|
|
168
|
+
if (t.external) {
|
|
169
|
+
t.resource = null;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
t.resource instanceof GPUBuffer ? this.bufferManager.releaseBuffer(t.resource) : t.resource instanceof GPUTexture && this.textureManager.releaseTexture(t.resource), t.resource = null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
refCount(e) {
|
|
176
|
+
return this.tensorMap.has(e) ? this.tensorMap.get(e).refCount : 0;
|
|
177
|
+
}
|
|
178
|
+
incRef(e) {
|
|
179
|
+
let t = this.tensorMap.get(e);
|
|
180
|
+
t.refCount++;
|
|
181
|
+
}
|
|
182
|
+
decRef(e) {
|
|
183
|
+
if (this.tensorMap.has(e)) {
|
|
184
|
+
let t = this.tensorMap.get(e);
|
|
185
|
+
t.refCount--;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
write(e, t, n) {
|
|
189
|
+
if (n === "complex64" && e != null) throw Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");
|
|
190
|
+
let r = { id: this.nextDataId() };
|
|
191
|
+
return this.tensorMap.set(r, {
|
|
192
|
+
dtype: n,
|
|
193
|
+
shape: t,
|
|
194
|
+
values: e,
|
|
195
|
+
refCount: 1
|
|
196
|
+
}), r;
|
|
197
|
+
}
|
|
198
|
+
move(e, t, n, r, i) {
|
|
199
|
+
if (r === "complex64") throw Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");
|
|
200
|
+
this.tensorMap.set(e, {
|
|
201
|
+
dtype: r,
|
|
202
|
+
shape: n,
|
|
203
|
+
values: t,
|
|
204
|
+
refCount: i
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
submitQueue() {
|
|
208
|
+
this.queue.submit([this.commandEncoder.finish()]), this.commandEncoder = null, this.dispatchCountInPass = 0, this.commandQueueOwnedIds = /* @__PURE__ */ new WeakSet(), this.tensorDataPendingDisposal.forEach((e) => {
|
|
209
|
+
this.releaseResource(e), this.tensorMap.delete(e);
|
|
210
|
+
}), this.uniformPendingDisposal.forEach((e) => this.bufferManager.releaseBuffer(e)), this.stagingPendingDisposal.forEach((e) => this.bufferManager.releaseBuffer(e, !1)), this.tensorDataPendingDisposal = [], this.uniformPendingDisposal = [], this.stagingPendingDisposal = [];
|
|
211
|
+
}
|
|
212
|
+
ensureCommandEncoderReady() {
|
|
213
|
+
this.commandEncoder ||= this.device.createCommandEncoder();
|
|
214
|
+
}
|
|
215
|
+
endComputePassEncoder() {
|
|
216
|
+
this.computePassEncoder &&= (this.computePassEncoder.end(), null);
|
|
217
|
+
}
|
|
218
|
+
async checkCompileCompletionAsync() {
|
|
219
|
+
let e;
|
|
220
|
+
try {
|
|
221
|
+
e = await Promise.all(Object.values(this.pipelineCache));
|
|
222
|
+
} catch (e) {
|
|
223
|
+
throw Error(e.message);
|
|
224
|
+
}
|
|
225
|
+
Object.keys(this.pipelineCache).map((t, n) => {
|
|
226
|
+
this.pipelineCache[t] = e[n];
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
async getBufferData(e) {
|
|
230
|
+
if (t().getBool("WEBGPU_ENGINE_COMPILE_ONLY")) return console.warn("The data may be invalid since WEBGPU_ENGINE_COMPILE_ONLY is true, this can only be called when WEBGPU_ENGINE_COMPILE_ONLY is false"), null;
|
|
231
|
+
let n = e.size, i = this.bufferManager.acquireBuffer(n, GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ);
|
|
232
|
+
this.ensureCommandEncoderReady(), this.endComputePassEncoder(), this.commandEncoder.copyBufferToBuffer(e, 0, i, 0, n), this.submitQueue(), await i.mapAsync(GPUMapMode.READ);
|
|
233
|
+
let a = i.getMappedRange().slice(0);
|
|
234
|
+
return i.unmap(), i != null && this.bufferManager.releaseBuffer(i), t().getBool("WEBGPU_USE_PROFILE_TOOL") && (r(this.dummyContext !== void 0, () => "Fail to get context for profiling tool"), this.dummyContext.getCurrentTexture()), a;
|
|
235
|
+
}
|
|
236
|
+
convertAndCacheOnCPU(e, t) {
|
|
237
|
+
let n = this.tensorMap.get(e);
|
|
238
|
+
return n.values = t, n.values;
|
|
239
|
+
}
|
|
240
|
+
readSync(e) {
|
|
241
|
+
let t = this.tensorMap.get(e), { values: n, complexTensorInfos: i } = t;
|
|
242
|
+
if (n != null || t.dtype === "string") return n;
|
|
243
|
+
if (t.dtype === "complex64") {
|
|
244
|
+
let t = m(h(this.readSync(i.real.dataId), this.readSync(i.imag.dataId)).buffer, "float32");
|
|
245
|
+
return this.convertAndCacheOnCPU(e, t), t;
|
|
246
|
+
}
|
|
247
|
+
this.hasReadSyncWarned || (this.hasReadSyncWarned = !0, console.warn("The performance of synchronously reading data from GPU to CPU is poor on the webgpu backend, please use asynchronous APIs instead."));
|
|
248
|
+
let a = ["opaque", "premultiplied"], o = t.resource, s = o.size;
|
|
249
|
+
r(s % 4 == 0, () => "Because there is 4 bytes for one pixel, buffer size must be multiple of 4.");
|
|
250
|
+
let c = s / 4, l = new ArrayBuffer(s), u = a.map((e) => new OffscreenCanvas(256, 256)), d = new OffscreenCanvas(256, 256);
|
|
251
|
+
this.endComputePassEncoder(), u.map((e, t) => {
|
|
252
|
+
let n = e.getContext("webgpu");
|
|
253
|
+
return n.configure({
|
|
254
|
+
device: this.device,
|
|
255
|
+
format: "bgra8unorm",
|
|
256
|
+
usage: GPUTextureUsage.COPY_DST,
|
|
257
|
+
alphaMode: a[t]
|
|
258
|
+
}), n.getCurrentTexture();
|
|
259
|
+
}).map((e, t) => {
|
|
260
|
+
let n = (n, r, i) => {
|
|
261
|
+
this.ensureCommandEncoderReady(), this.commandEncoder.copyBufferToTexture({
|
|
262
|
+
buffer: o,
|
|
263
|
+
bytesPerRow: 1024,
|
|
264
|
+
offset: i
|
|
265
|
+
}, { texture: e }, {
|
|
266
|
+
width: n,
|
|
267
|
+
height: r
|
|
268
|
+
}), this.submitQueue();
|
|
269
|
+
let s = d.getContext("2d", { willReadFrequently: !0 });
|
|
270
|
+
s.clearRect(0, 0, n, r), s.drawImage(u[t], 0, 0);
|
|
271
|
+
let c = s.getImageData(0, 0, n, r).data, f = a[t], p = new Uint8ClampedArray(l, i, n * r * 4);
|
|
272
|
+
for (let e = 0; e < p.length; e += 4) if (f === "premultiplied") p[e + 3] = c[e + 3];
|
|
273
|
+
else {
|
|
274
|
+
let t = c[e];
|
|
275
|
+
p[e] = c[e + 2], p[e + 1] = c[e + 1], p[e + 2] = t;
|
|
276
|
+
}
|
|
277
|
+
}, r = Math.floor(c / (256 * 256)), i = 256, s = 256, f = 0;
|
|
278
|
+
for (let e = 0; e < r; e++) n(i, s, f), f += 256 * 256 * 4;
|
|
279
|
+
let p = c % (256 * 256);
|
|
280
|
+
s = Math.floor(p / 256), s > 0 && (n(i, s, f), f += 256 * 4 * s), i = p % 256, i > 0 && n(i, 1, f);
|
|
281
|
+
});
|
|
282
|
+
let f = m(l, t.dtype);
|
|
283
|
+
return this.convertAndCacheOnCPU(e, f), f;
|
|
284
|
+
}
|
|
285
|
+
async read(e) {
|
|
286
|
+
if (!this.tensorMap.has(e)) throw Error(`Tensor ${e} was not registered!`);
|
|
287
|
+
let t = this.tensorMap.get(e), { values: n } = t;
|
|
288
|
+
if (n != null) return n;
|
|
289
|
+
let r;
|
|
290
|
+
if (t.dtype === "complex64") {
|
|
291
|
+
let e = await Promise.all([this.read(t.complexTensorInfos.real.dataId), this.read(t.complexTensorInfos.imag.dataId)]), n = e[0], i = e[1];
|
|
292
|
+
r = h(n, i);
|
|
293
|
+
} else r = m(await this.getBufferData(t.resource), t.dtype);
|
|
294
|
+
return this.convertAndCacheOnCPU(e, r), r;
|
|
295
|
+
}
|
|
296
|
+
copyBuffer(e) {
|
|
297
|
+
let t = e.size, n = e.usage, r = this.bufferManager.acquireBuffer(t, n);
|
|
298
|
+
return this.ensureCommandEncoderReady(), this.endComputePassEncoder(), this.commandEncoder.copyBufferToBuffer(e, 0, r, 0, t), this.submitQueue(), r;
|
|
299
|
+
}
|
|
300
|
+
createTensorFromGPUData(e, t, n) {
|
|
301
|
+
let r = e.buffer;
|
|
302
|
+
if (n === "complex64") throw Error("Cannot write to a complex64 dtype. ");
|
|
303
|
+
let i = { id: this.nextDataId() };
|
|
304
|
+
this.tensorMap.set(i, {
|
|
305
|
+
dtype: n,
|
|
306
|
+
shape: t,
|
|
307
|
+
values: null,
|
|
308
|
+
refCount: 1,
|
|
309
|
+
external: e.zeroCopy
|
|
310
|
+
});
|
|
311
|
+
let a = this.tensorMap.get(i), o = b(a.dtype) * f(a.shape);
|
|
312
|
+
if (e.buffer.size < o) throw Error(`GPUBuffer size(${e.buffer.size}) is smaller than tensor size(${o})!`);
|
|
313
|
+
if ((e.buffer.usage & (GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC)) !== (GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC)) throw Error("GPUBuffer.usage should include GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC!");
|
|
314
|
+
return e.zeroCopy !== !0 && (r = this.copyBuffer(r)), a.resource = r, l().makeTensorFromDataId(i, t, n, this);
|
|
315
|
+
}
|
|
316
|
+
readToGPU(e) {
|
|
317
|
+
let { values: t, dtype: n, shape: r, resource: i } = this.tensorMap.get(e);
|
|
318
|
+
if (n === "complex64") throw Error("Does not support reading buffer for complex64 dtype.");
|
|
319
|
+
if (i == null) throw Error(t == null ? "There is no data on GPU or CPU." : "Data is not on GPU but on CPU.");
|
|
320
|
+
let a = i, o = a.size, s = a.usage, c = this.bufferManager.acquireBuffer(o, s);
|
|
321
|
+
this.ensureCommandEncoderReady(), this.endComputePassEncoder(), this.commandEncoder.copyBufferToBuffer(i, 0, c, 0, o), this.submitQueue();
|
|
322
|
+
let u = this.makeTensorInfo(r, n), d = l().makeTensorFromTensorInfo(u), f = this.tensorMap.get(u.dataId);
|
|
323
|
+
return f.resource = c, {
|
|
324
|
+
tensorRef: d,
|
|
325
|
+
buffer: c
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
bufferSync(e) {
|
|
329
|
+
let t = this.readSync(e.dataId);
|
|
330
|
+
if (e.dtype === "string") try {
|
|
331
|
+
let r = t.map((e) => n(e));
|
|
332
|
+
return o(e.shape, e.dtype, r);
|
|
333
|
+
} catch {
|
|
334
|
+
throw Error("Failed to decode encoded string bytes into utf-8");
|
|
335
|
+
}
|
|
336
|
+
return o(e.shape, e.dtype, t);
|
|
337
|
+
}
|
|
338
|
+
async time(t) {
|
|
339
|
+
!this.supportTimestampQuery && !this.hasTimestampQueryWarned && (console.warn("This device doesn't support timestamp-query extension. Start Chrome browser with flag --enable-dawn-features=allow_unsafe_apis to try it again. Otherwise, zero will be shown for the kernel time when profiling mode is enabled."), this.hasTimestampQueryWarned = !0);
|
|
340
|
+
let n = this.activeTimers, r = [], i = !1;
|
|
341
|
+
this.programTimersStack == null ? (this.programTimersStack = r, i = !0) : this.activeTimers.push(r), this.activeTimers = r, t();
|
|
342
|
+
let a = e(this.activeTimers.map((e) => e.query)).filter((e) => e != null), o = e(this.activeTimers.map((e) => e.name)).filter((e) => e != null);
|
|
343
|
+
this.activeTimers = n, i && (this.programTimersStack = null);
|
|
344
|
+
let s = {
|
|
345
|
+
uploadWaitMs: this.uploadWaitMs,
|
|
346
|
+
downloadWaitMs: this.downloadWaitMs,
|
|
347
|
+
kernelMs: null,
|
|
348
|
+
wallMs: null
|
|
349
|
+
}, c = await Promise.all(a);
|
|
350
|
+
return s.kernelMs = d(c), s.getExtraProfileInfo = () => c.map((e, t) => ({
|
|
351
|
+
name: o[t],
|
|
352
|
+
ms: e
|
|
353
|
+
})).map((e) => `${e.name}: ${e.ms}`).join(", "), this.uploadWaitMs = 0, this.downloadWaitMs = 0, s;
|
|
354
|
+
}
|
|
355
|
+
makeTensorInfo(e, t, n) {
|
|
356
|
+
return t === "string" && n != null && n.length > 0 && s(n[0]) && (n = n.map((e) => u(e))), {
|
|
357
|
+
dataId: this.write(n, e, t),
|
|
358
|
+
shape: e,
|
|
359
|
+
dtype: t
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
tensorToBinding(e) {
|
|
363
|
+
if (!e) return null;
|
|
364
|
+
let t = this.tensorMap.get(e.dataId).resource;
|
|
365
|
+
return t instanceof GPUBuffer ? { buffer: t } : t instanceof GPUTexture ? t.createView() : t;
|
|
366
|
+
}
|
|
367
|
+
uploadToGPU(e) {
|
|
368
|
+
let t = this.tensorMap.get(e);
|
|
369
|
+
if (t.resource != null) return;
|
|
370
|
+
let n = b(t.dtype) * f(t.shape), r, i = GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST;
|
|
371
|
+
if (t.values) {
|
|
372
|
+
if (r = this.bufferManager.acquireBuffer(n, i, !0), r.mapState === "unmapped") {
|
|
373
|
+
let e = this.bufferManager.acquireBuffer(n, GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC, !0, !1), i = e.getMappedRange();
|
|
374
|
+
t.dtype === "int32" || t.dtype === "packedF16" || t.dtype === "bool" ? new Int32Array(i).set(t.values) : new Float32Array(i).set(t.values), e.unmap(), this.ensureCommandEncoderReady(), this.endComputePassEncoder(), this.commandEncoder.copyBufferToBuffer(e, 0, r, 0, n), this.stagingPendingDisposal.push(e);
|
|
375
|
+
} else {
|
|
376
|
+
let e = r.getMappedRange();
|
|
377
|
+
t.dtype === "int32" || t.dtype === "packedF16" || t.dtype === "bool" ? new Int32Array(e).set(t.values) : new Float32Array(e).set(t.values), r.unmap();
|
|
378
|
+
}
|
|
379
|
+
t.values = null;
|
|
380
|
+
} else r = this.bufferManager.acquireBuffer(n, i);
|
|
381
|
+
t.resource = r;
|
|
382
|
+
}
|
|
383
|
+
makeUniforms(e) {
|
|
384
|
+
let t = 0, n = 0, i = [], a = 1;
|
|
385
|
+
e.forEach((e) => {
|
|
386
|
+
e.data.length === 0 && (e.data = [1]);
|
|
387
|
+
let o;
|
|
388
|
+
switch (e.data.length) {
|
|
389
|
+
case 1:
|
|
390
|
+
o = 4;
|
|
391
|
+
break;
|
|
392
|
+
case 2:
|
|
393
|
+
o = 8;
|
|
394
|
+
break;
|
|
395
|
+
case 3:
|
|
396
|
+
o = 16;
|
|
397
|
+
break;
|
|
398
|
+
case 4:
|
|
399
|
+
o = 16;
|
|
400
|
+
break;
|
|
401
|
+
case 5:
|
|
402
|
+
o = 16;
|
|
403
|
+
break;
|
|
404
|
+
case 6:
|
|
405
|
+
o = 16;
|
|
406
|
+
break;
|
|
407
|
+
default: r(!1, () => `Unsupported ${e.data.length}D shape`);
|
|
408
|
+
}
|
|
409
|
+
(n === 5 || n === 6) && (o = 16), o > a && (a = o), t = Math.ceil(t / o) * o, n = e.data.length, i.push(t), t += e.data.length * 4;
|
|
410
|
+
}), t = Math.ceil(t / a) * a;
|
|
411
|
+
let o = new ArrayBuffer(t);
|
|
412
|
+
e.forEach((e, t) => {
|
|
413
|
+
let n = i[t];
|
|
414
|
+
e.type === "int32" ? new Int32Array(o, n, e.data.length).set(e.data) : e.type === "uint32" ? new Uint32Array(o, n, e.data.length).set(e.data) : new Float32Array(o, n, e.data.length).set(e.data);
|
|
415
|
+
});
|
|
416
|
+
let s = this.bufferManager.acquireBuffer(t, GPUBufferUsage.COPY_DST | GPUBufferUsage.UNIFORM);
|
|
417
|
+
return this.queue.writeBuffer(s, 0, o, 0, t), this.uniformPendingDisposal.push(s), {
|
|
418
|
+
offset: 0,
|
|
419
|
+
size: t,
|
|
420
|
+
buffer: s
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
runWebGPUProgram(e, n, r, i, o) {
|
|
424
|
+
if (o ||= this.makeTensorInfo(e.outputShape, r), f(o.shape) === 0) return this.tensorMap.get(o.dataId).values = a(o.dtype, 0), o;
|
|
425
|
+
this.uploadToGPU(o.dataId), e.dispatch = k(this.device, e);
|
|
426
|
+
let s = n.map((t, n) => {
|
|
427
|
+
if (t.dtype === "complex64") throw Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");
|
|
428
|
+
return this.uploadToGPU(t.dataId), {
|
|
429
|
+
dtype: this.tensorMap.get(t.dataId).dtype,
|
|
430
|
+
shape: t.shape,
|
|
431
|
+
name: e.variableNames[n]
|
|
432
|
+
};
|
|
433
|
+
});
|
|
434
|
+
e.shaderKey = g(e, s, o);
|
|
435
|
+
let c = t().getBool("WEBGPU_ENGINE_COMPILE_ONLY");
|
|
436
|
+
return e.shaderKey in this.pipelineCache || (this.pipelineCache[e.shaderKey] = _(this.device, e, s, o, c)), e.pipeline = this.pipelineCache[e.shaderKey], c || this.recordAndSubmit(e, o, n, i), o;
|
|
437
|
+
}
|
|
438
|
+
recordAndSubmit(e, n, r, a) {
|
|
439
|
+
if (e.pipeline instanceof Promise) throw Error("Please call checkCompileCompletionAsync to ensure parallel compilation is done!");
|
|
440
|
+
let o = [], s = [], c = "int32";
|
|
441
|
+
if (e.pixelsOpType == null) {
|
|
442
|
+
o.push({
|
|
443
|
+
type: "float32",
|
|
444
|
+
data: [NaN]
|
|
445
|
+
}, {
|
|
446
|
+
type: "float32",
|
|
447
|
+
data: [Infinity]
|
|
448
|
+
}), s = r.concat(n).map((e) => e.shape);
|
|
449
|
+
let e = "int32";
|
|
450
|
+
s.map((t) => {
|
|
451
|
+
o.push({
|
|
452
|
+
type: e,
|
|
453
|
+
data: t
|
|
454
|
+
});
|
|
455
|
+
let n = i(t);
|
|
456
|
+
o.push({
|
|
457
|
+
type: e,
|
|
458
|
+
data: n
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
} else {
|
|
462
|
+
let e = i(n.shape);
|
|
463
|
+
o.push({
|
|
464
|
+
type: c,
|
|
465
|
+
data: e
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
if (e.size) {
|
|
469
|
+
let t = f(e.outputShape);
|
|
470
|
+
o.push({
|
|
471
|
+
type: c,
|
|
472
|
+
data: [e.outputComponent ? t / e.outputComponent : t]
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
a && (o = [...o, ...a]);
|
|
476
|
+
let l = [
|
|
477
|
+
this.tensorToBinding(n),
|
|
478
|
+
...r.map((e) => this.tensorToBinding(e)),
|
|
479
|
+
this.makeUniforms(o)
|
|
480
|
+
];
|
|
481
|
+
r.forEach((e) => {
|
|
482
|
+
this.commandQueueOwnedIds.add(e.dataId);
|
|
483
|
+
}), this.commandQueueOwnedIds.add(n.dataId);
|
|
484
|
+
let u = this.device.createBindGroup({
|
|
485
|
+
layout: e.pipeline.getBindGroupLayout(0),
|
|
486
|
+
entries: l.map((e, t) => ({
|
|
487
|
+
binding: t,
|
|
488
|
+
resource: e
|
|
489
|
+
}))
|
|
490
|
+
}), d = this.activeTimers != null;
|
|
491
|
+
this.ensureCommandEncoderReady();
|
|
492
|
+
let p = {};
|
|
493
|
+
d && this.supportTimestampQuery ? (this.endComputePassEncoder(), this.querySet ??= this.device.createQuerySet({
|
|
494
|
+
type: "timestamp",
|
|
495
|
+
count: this.querySetCount
|
|
496
|
+
}), p.timestampWrites = {
|
|
497
|
+
querySet: this.querySet,
|
|
498
|
+
beginningOfPassWriteIndex: 0,
|
|
499
|
+
endOfPassWriteIndex: 1
|
|
500
|
+
}, this.computePassEncoder = this.commandEncoder.beginComputePass(p)) : this.computePassEncoder ||= this.commandEncoder.beginComputePass(p), this.computePassEncoder.setPipeline(e.pipeline), this.computePassEncoder.setBindGroup(0, u), this.computePassEncoder.dispatchWorkgroups(e.dispatch[0], e.dispatch[1], e.dispatch[2]), this.dispatchCountInPass++, (d || t().get("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE") <= this.dispatchCountInPass || e.pixelsOpType === v.DRAW) && (this.endComputePassEncoder(), d ? this.activeTimers.push({
|
|
501
|
+
name: e.constructor.name,
|
|
502
|
+
query: this.getQueryTime()
|
|
503
|
+
}) : this.submitQueue());
|
|
504
|
+
}
|
|
505
|
+
async getQueryTime() {
|
|
506
|
+
if (!this.supportTimestampQuery) return 0;
|
|
507
|
+
this.queryResolveBuffer ??= this.bufferManager.acquireBuffer(this.querySetCount * 8, GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST | GPUBufferUsage.QUERY_RESOLVE), this.commandEncoder.resolveQuerySet(this.querySet, 0, this.querySetCount, this.queryResolveBuffer, 0);
|
|
508
|
+
let e = this.bufferManager.acquireBuffer(this.querySetCount * 8, GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST);
|
|
509
|
+
this.commandEncoder.copyBufferToBuffer(this.queryResolveBuffer, 0, e, 0, this.querySetCount * 8), this.submitQueue(), await e.mapAsync(GPUMapMode.READ);
|
|
510
|
+
let t = new BigUint64Array(e.getMappedRange()), n = Number(t[1] - t[0]) / 1e6;
|
|
511
|
+
return e.unmap(), this.bufferManager.releaseBuffer(e), n;
|
|
512
|
+
}
|
|
513
|
+
shouldExecuteOnCPU(e, n = O) {
|
|
514
|
+
return t().getBool("WEBGPU_CPU_FORWARD") && e.every((e) => this.tensorMap.get(e.dataId).resource == null && f(e.shape) < n);
|
|
515
|
+
}
|
|
516
|
+
numDataIds() {
|
|
517
|
+
return this.tensorMap.numDataIds() - this.tensorDataPendingDisposal.length;
|
|
518
|
+
}
|
|
519
|
+
dispose() {
|
|
520
|
+
this.disposed ||= (this.querySet != null && this.querySet.destroy(), this.bufferManager.dispose(), this.textureManager.dispose(), !0);
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
A.nextDataId = 0;
|
|
524
|
+
//#endregion
|
|
525
|
+
export { A as t };
|