@genai-fi/nanogpt 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +352 -14
- package/dist/Generator.js +69 -78
- package/dist/{RealDiv-D4EzDsC0.js → RealDiv-DgA3z9oO.js} +32 -206
- package/dist/Reshape-CF6odzV4.js +16 -0
- package/dist/Reshape-_kILl6tK.js +81 -0
- package/dist/TeachableLLM.js +28 -22
- package/dist/Trainer.d.ts +2 -0
- package/dist/Trainer.js +3 -2
- package/dist/{axis_util-TbGYJ208.js → axis_util-BvHEw88j.js} +7 -23
- package/dist/backend.d.ts +2 -1
- package/dist/backend.js +10 -4
- package/dist/backend_util-D-rUb2ty.js +474 -0
- package/dist/backend_webgpu-B0u2ndUn.js +547 -0
- package/dist/binary_op_util-pKXltfxI.js +192 -0
- package/dist/broadcast_to-CwF7XIeu.js +30 -0
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +3 -3
- package/dist/checks/check.d.ts +1 -1
- package/dist/checks/check.js +8 -8
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/index.d.ts +2 -0
- package/dist/checks/index.js +7 -5
- package/dist/checks/matMulGelu.js +6 -6
- package/dist/checks/normRMS.js +7 -7
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/packUnpack.d.ts +1 -0
- package/dist/checks/packUnpack.js +18 -0
- package/dist/checks/qkv.js +12 -27
- package/dist/checks/rope.js +2 -2
- package/dist/checks/weights.js +18 -16
- package/dist/complex-CSlYz-2T.js +13 -0
- package/dist/complex_util-Yc1A_gV1.js +55 -0
- package/dist/concat-BHlIJeyT.js +19 -0
- package/dist/concat_util-DcJk7YHS.js +22 -0
- package/dist/data/docx.js +1 -1
- package/dist/data/parquet.js +2 -2
- package/dist/data/pdf.js +1 -1
- package/dist/data/textLoader.js +1 -1
- package/dist/{dataset-DlZtKmBq.js → dataset-0xP8GjwI.js} +136 -236
- package/dist/dropout-C1pM3f11.js +99 -0
- package/dist/expand_dims-BPG4fwBP.js +13 -0
- package/dist/exports_initializers-xuidcwI4.js +7 -0
- package/dist/gather-DykLGqmW.js +10 -0
- package/dist/{gelu-Bp_-935b.js → gelu-CNLFZWea.js} +11 -10
- package/dist/{gpgpu_math-CDaYiyE_.js → gpgpu_math-DDVJCn6-.js} +90 -265
- package/dist/{index-C4L8Cm77.js → index-CieiGp4Y.js} +14 -14
- package/dist/index-CjOj7j-u.js +7308 -0
- package/dist/{index-Tf7vU29b.js → index-Cp39cXWe.js} +3 -10
- package/dist/{index-Dwqa6Zy2.js → index-DvYrXKkX.js} +2 -2
- package/dist/index-ZyQhjEPo.js +2157 -0
- package/dist/{jszip.min-CjP2V1VV.js → jszip.min-Bz5-11Bk.js} +56 -57
- package/dist/kernel_funcs_utils-Dg_-E44D.js +308 -0
- package/dist/layers/BaseLayer.d.ts +1 -0
- package/dist/layers/BaseLayer.js +7 -6
- package/dist/layers/CausalSelfAttention.d.ts +0 -1
- package/dist/layers/CausalSelfAttention.js +56 -55
- package/dist/layers/MLP.js +15 -16
- package/dist/layers/PositionEmbedding.js +5 -14
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.d.ts +2 -0
- package/dist/layers/RoPECache.js +22 -17
- package/dist/layers/TiedEmbedding.js +22 -17
- package/dist/layers/TransformerBlock.js +21 -20
- package/dist/loader/load.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +39 -33
- package/dist/loader/save.js +1 -1
- package/dist/log_sum_exp-DWI-76TI.js +41 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.js +63 -52
- package/dist/matMul16--R5hOwDG.js +77 -0
- package/dist/mat_mul-DeAh4uTH.js +12 -0
- package/dist/mod-Gt1rMB4n.js +12 -0
- package/dist/models/NanoGPTV1.js +40 -31
- package/dist/models/model.d.ts +2 -0
- package/dist/models/model.js +37 -29
- package/dist/{mulmat_packed_gpu-BT60jmzP.js → mulmat_packed_gpu-BMFhLwta.js} +1 -17
- package/dist/{non_max_suppression_impl-CsEgBuMA.js → non_max_suppression_impl-B2W7YjZB.js} +0 -32
- package/dist/ones-CAMiP4I2.js +15 -0
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.d.ts +1 -1
- package/dist/ops/adamMoments.js +4 -4
- package/dist/ops/add16.d.ts +2 -0
- package/dist/ops/add16.js +9 -0
- package/dist/ops/appendCache.js +16 -9
- package/dist/ops/attentionMask.js +4 -4
- package/dist/ops/concat16.d.ts +2 -0
- package/dist/ops/concat16.js +9 -0
- package/dist/ops/cpu/adamAdjust.js +14 -13
- package/dist/ops/cpu/adamMoments.js +10 -9
- package/dist/ops/cpu/appendCache.js +9 -8
- package/dist/ops/cpu/attentionMask.js +15 -14
- package/dist/ops/cpu/fusedSoftmax.js +13 -12
- package/dist/ops/cpu/gatherSub.js +9 -24
- package/dist/ops/cpu/gelu.js +13 -12
- package/dist/ops/cpu/matMul16.d.ts +1 -0
- package/dist/ops/cpu/matMul16.js +16 -0
- package/dist/ops/cpu/matMulGelu.js +18 -16
- package/dist/ops/cpu/matMulMul.js +8 -7
- package/dist/ops/cpu/mulDropout.js +4 -3
- package/dist/ops/cpu/normRMS.js +11 -10
- package/dist/ops/cpu/qkv.js +17 -13
- package/dist/ops/cpu/rope.js +23 -22
- package/dist/ops/cpu/scatterSub.js +16 -30
- package/dist/ops/dot16.d.ts +2 -0
- package/dist/ops/dot16.js +42 -0
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/add16.d.ts +1 -0
- package/dist/ops/grads/add16.js +27 -0
- package/dist/ops/grads/attentionMask.js +12 -19
- package/dist/ops/grads/gelu.js +4 -3
- package/dist/ops/grads/matMul16.d.ts +2 -0
- package/dist/ops/grads/matMul16.js +9 -0
- package/dist/ops/grads/matMulGelu.js +8 -7
- package/dist/ops/grads/normRMS.js +8 -7
- package/dist/ops/grads/{fusedSoftmax.d.ts → pack16.d.ts} +1 -1
- package/dist/ops/grads/pack16.js +7 -0
- package/dist/ops/grads/qkv.d.ts +3 -1
- package/dist/ops/grads/qkv.js +28 -22
- package/dist/ops/grads/rope.d.ts +2 -1
- package/dist/ops/grads/rope.js +6 -13
- package/dist/ops/grads/softmax16.d.ts +2 -0
- package/dist/ops/grads/softmax16.js +26 -0
- package/dist/ops/grads/unpack16.d.ts +2 -0
- package/dist/ops/grads/unpack16.js +6 -0
- package/dist/ops/grads/utils.d.ts +3 -0
- package/dist/ops/grads/utils.js +10 -0
- package/dist/ops/matMul16.d.ts +15 -0
- package/dist/ops/matMul16.js +13 -0
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mul16.d.ts +2 -0
- package/dist/ops/mul16.js +8 -0
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/pack16.d.ts +2 -0
- package/dist/ops/pack16.js +6 -0
- package/dist/ops/qkv.d.ts +1 -1
- package/dist/ops/qkv.js +8 -4
- package/dist/ops/reshape16.d.ts +2 -0
- package/dist/ops/reshape16.js +43 -0
- package/dist/ops/rope.d.ts +1 -1
- package/dist/ops/rope.js +8 -10
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/slice16.d.ts +2 -0
- package/dist/ops/slice16.js +9 -0
- package/dist/ops/softmax16.d.ts +2 -0
- package/dist/ops/softmax16.js +12 -0
- package/dist/ops/sub16.d.ts +2 -0
- package/dist/ops/sub16.js +8 -0
- package/dist/ops/sum16.d.ts +2 -0
- package/dist/ops/sum16.js +13 -0
- package/dist/ops/transpose16.d.ts +3 -0
- package/dist/ops/transpose16.js +41 -0
- package/dist/ops/unpack16.d.ts +2 -0
- package/dist/ops/unpack16.js +6 -0
- package/dist/ops/webgl/adamAdjust.js +3 -2
- package/dist/ops/webgl/adamMoments.js +2 -1
- package/dist/ops/webgl/appendCache.js +2 -1
- package/dist/ops/webgl/attentionMask.js +5 -4
- package/dist/ops/webgl/fusedSoftmax.js +6 -4
- package/dist/ops/webgl/gatherSub.js +7 -6
- package/dist/ops/webgl/gelu.js +3 -2
- package/dist/ops/webgl/log.js +12 -27
- package/dist/ops/webgl/matMul16.d.ts +1 -0
- package/dist/ops/webgl/matMul16.js +37 -0
- package/dist/ops/webgl/matMulGelu.js +17 -15
- package/dist/ops/webgl/matMulMul.js +13 -12
- package/dist/ops/webgl/mulDropout.js +9 -8
- package/dist/ops/webgl/normRMS.js +8 -7
- package/dist/ops/webgl/qkv.js +6 -5
- package/dist/ops/webgl/rope.js +11 -10
- package/dist/ops/webgl/scatterSub.js +6 -5
- package/dist/ops/webgpu/adamAdjust.js +12 -10
- package/dist/ops/webgpu/adamMoments.js +27 -22
- package/dist/ops/webgpu/add16.d.ts +1 -0
- package/dist/ops/webgpu/add16.js +14 -0
- package/dist/ops/webgpu/appendCache.js +64 -17
- package/dist/ops/webgpu/attentionMask.js +19 -62
- package/dist/ops/webgpu/attentionMask32_program.d.ts +19 -0
- package/dist/ops/webgpu/attentionMask32_program.js +54 -0
- package/dist/ops/webgpu/concat16.d.ts +19 -0
- package/dist/ops/webgpu/concat16.js +128 -0
- package/dist/ops/webgpu/gatherSub.js +9 -7
- package/dist/ops/webgpu/gelu.js +78 -31
- package/dist/ops/webgpu/index.js +12 -0
- package/dist/ops/webgpu/matMul16.d.ts +1 -0
- package/dist/ops/webgpu/matMul16.js +58 -0
- package/dist/ops/webgpu/matMul16_program.d.ts +42 -0
- package/dist/ops/webgpu/matMul16_program.js +336 -0
- package/dist/ops/webgpu/mul16.d.ts +1 -0
- package/dist/ops/webgpu/mul16.js +14 -0
- package/dist/ops/webgpu/normRMS.js +21 -40
- package/dist/ops/webgpu/normRMS16_program.d.ts +9 -0
- package/dist/ops/webgpu/normRMS16_program.js +24 -0
- package/dist/ops/webgpu/normRMS32_program.d.ts +9 -0
- package/dist/ops/webgpu/normRMS32_program.js +24 -0
- package/dist/ops/webgpu/normRMSGrad.js +113 -64
- package/dist/ops/webgpu/pack16.d.ts +1 -0
- package/dist/ops/webgpu/pack16.js +19 -0
- package/dist/ops/webgpu/pack16_program.d.ts +19 -0
- package/dist/ops/webgpu/pack16_program.js +92 -0
- package/dist/ops/webgpu/qkv.js +20 -55
- package/dist/ops/webgpu/rope.js +77 -22
- package/dist/ops/webgpu/scatterSub.js +9 -7
- package/dist/ops/webgpu/slice16.d.ts +7 -0
- package/dist/ops/webgpu/slice16.js +71 -0
- package/dist/{variable-Bm2OFwGI.js → ops/webgpu/softmax16.d.ts} +2 -8
- package/dist/ops/webgpu/softmax16.js +23 -0
- package/dist/ops/webgpu/softmax16_program.d.ts +13 -0
- package/dist/ops/webgpu/softmax16_program.js +73 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.d.ts +17 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.js +75 -0
- package/dist/ops/webgpu/softmax16grad.d.ts +1 -0
- package/dist/ops/webgpu/softmax16grad.js +38 -0
- package/dist/ops/webgpu/sub16.d.ts +1 -0
- package/dist/ops/webgpu/sub16.js +14 -0
- package/dist/ops/webgpu/sum16.d.ts +1 -0
- package/dist/ops/webgpu/sum16.js +40 -0
- package/dist/ops/webgpu/transpose16.d.ts +1 -0
- package/dist/ops/webgpu/transpose16.js +35 -0
- package/dist/ops/webgpu/transpose16_program.d.ts +16 -0
- package/dist/ops/webgpu/transpose16_program.js +50 -0
- package/dist/ops/webgpu/transpose16_shared_program.d.ts +15 -0
- package/dist/ops/webgpu/transpose16_shared_program.js +71 -0
- package/dist/ops/webgpu/unpack16.d.ts +1 -0
- package/dist/ops/webgpu/unpack16.js +49 -0
- package/dist/ops/webgpu/utils/binary_op.d.ts +19 -0
- package/dist/ops/webgpu/utils/binary_op.js +79 -0
- package/dist/ops/webgpu/utils/deviceInfo.d.ts +7 -0
- package/dist/ops/webgpu/utils/deviceInfo.js +11 -0
- package/dist/ops/webgpu/utils/reductions.d.ts +32 -4
- package/dist/ops/webgpu/utils/reductions.js +236 -45
- package/dist/ops-CNI3TwqM.js +645 -0
- package/dist/pack16-CFUqumar.js +41 -0
- package/dist/{papaparse.min-C8l2Kvo1.js → papaparse.min-C0cScC2i.js} +2 -8
- package/dist/{parquet-C0Tlmv9c.js → parquet-BE8MU_ge.js} +201 -278
- package/dist/patches/PackedTensor.d.ts +12 -0
- package/dist/patches/PackedTensor.js +11 -0
- package/dist/patches/engine.d.ts +261 -0
- package/dist/patches/engine.js +10 -0
- package/dist/patches/tape.d.ts +12 -0
- package/dist/patches/tape.js +5 -0
- package/dist/patches/webgpu_backend.d.ts +18 -0
- package/dist/patches/webgpu_backend.js +57 -0
- package/dist/{tensor-CZr4dh61.js → patches/webgpu_base.d.ts} +5 -8
- package/dist/patches/webgpu_base.js +34 -0
- package/dist/patches/webgpu_program.d.ts +36 -0
- package/dist/patches/webgpu_program.js +401 -0
- package/dist/{pdf-kJD-f258.js → pdf-NIhmP3sq.js} +424 -428
- package/dist/random_width-DY6Kk2Dl.js +10051 -0
- package/dist/range-BMS52eQi.js +11 -0
- package/dist/reciprocal-CTmshQ9J.js +10 -0
- package/dist/{register_all_kernels-DIGpEwcf.js → register_all_kernels-Bwu1PTuU.js} +719 -9766
- package/dist/relu-yZ2-7WxU.js +10 -0
- package/dist/reshape-DevtBWtf.js +10 -0
- package/dist/rope-B5UUMsPi.js +32 -0
- package/dist/{scatter_nd_util-BQdz--Gn.js → scatter_nd_util-5EL-8VAQ.js} +1 -1
- package/dist/selu_util-D1w6yyTO.js +303 -0
- package/dist/{shared-DuP7ue-R.js → shared-BRksrJb3.js} +1 -17
- package/dist/shared-BuAXb4CI.js +2145 -0
- package/dist/sin-BGfy2HZo.js +16 -0
- package/dist/slice-D_gkkqZK.js +13 -0
- package/dist/slice_util-DtEldBfK.js +261 -0
- package/dist/softmax-ZHVebtR1.js +13 -0
- package/dist/split-DrfihRpZ.js +10 -0
- package/dist/squeeze-DZEpeblb.js +11 -0
- package/dist/stack-yOIAalTq.js +13 -0
- package/dist/sum-_fzj5ZTB.js +12 -0
- package/dist/tensor-DdQUJZlz.js +909 -0
- package/dist/tensor-f35l8Odg.js +8 -0
- package/dist/tensor1d-CeZuc-Rv.js +12 -0
- package/dist/tensor2d-G4Ys2GxX.js +15 -0
- package/dist/tensor4d-B8roDgtc.js +15 -0
- package/dist/tensor_util-DV-FP5Q3.js +523 -0
- package/dist/tfjs_backend-kNyO5L2d.js +653 -0
- package/dist/tile-BzyEiF-F.js +13 -0
- package/dist/tokeniser/CharTokeniser.js +1 -1
- package/dist/tokeniser/bpe.js +1 -1
- package/dist/training/Adam.d.ts +2 -1
- package/dist/training/Adam.js +12 -28
- package/dist/training/AdamExt.d.ts +1 -0
- package/dist/training/AdamExt.js +2 -2
- package/dist/training/DatasetBuilder.js +3 -20
- package/dist/training/FullTrainer.js +82 -64
- package/dist/training/Trainer.d.ts +11 -6
- package/dist/training/Trainer.js +51 -39
- package/dist/training/sparseCrossEntropy.js +3 -3
- package/dist/transpose-DKELTqhe.js +38 -0
- package/dist/utilities/arrayClose.js +7 -7
- package/dist/utilities/dummy.js +35 -27
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/packed.d.ts +7 -0
- package/dist/utilities/packed.js +716 -0
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/sentences.d.ts +5 -0
- package/dist/utilities/sentences.js +41 -0
- package/dist/utilities/weights.js +2 -2
- package/dist/variable-Bhn5bHYv.js +7 -0
- package/dist/{webgpu_program-DkQJOJSd.js → webgpu_program-Cigz-7RF.js} +15 -44
- package/dist/webgpu_util-BBCnKm2X.js +65 -0
- package/dist/zeros-2gldETuK.js +14 -0
- package/package.json +4 -3
- package/dist/Reshape-Bowtk9BP.js +0 -127
- package/dist/Reshape-DUqYftGC.js +0 -30
- package/dist/backend_util-CJIiDoV1.js +0 -749
- package/dist/broadcast_to-DzlNweb8.js +0 -44
- package/dist/concat-B912vBbo.js +0 -33
- package/dist/dropout-C-csYCLj.js +0 -193
- package/dist/exports_initializers-B8iZMgQ0.js +0 -16
- package/dist/gather-Dnpgw-YQ.js +0 -25
- package/dist/index-BzFyqcy-.js +0 -4457
- package/dist/index-C1rx_Ajs.js +0 -12076
- package/dist/kernel_funcs_utils-DKLK0Mg3.js +0 -466
- package/dist/log_sum_exp-DO6z8tSE.js +0 -103
- package/dist/mat_mul-DzjTFx-u.js +0 -27
- package/dist/mod-Dobti4j4.js +0 -27
- package/dist/ones-tIJeHlq-.js +0 -29
- package/dist/ops/fusedSoftmax.d.ts +0 -2
- package/dist/ops/fusedSoftmax.js +0 -10
- package/dist/ops/grads/fusedSoftmax.js +0 -22
- package/dist/ops-LuCMAnmM.js +0 -1525
- package/dist/random_width-CXVRloNK.js +0 -13670
- package/dist/range-CWcz7xFA.js +0 -26
- package/dist/reciprocal-C4rNcM-S.js +0 -25
- package/dist/relu-BjCh_SYb.js +0 -25
- package/dist/reshape-CnIwVG1c.js +0 -25
- package/dist/selu_util-OtRzVwW5.js +0 -719
- package/dist/shared-DmRsFyaJ.js +0 -3134
- package/dist/sin-gpDNRxE0.js +0 -47
- package/dist/slice-d0Vo9XTN.js +0 -28
- package/dist/softmax-D7Jj3p_P.js +0 -28
- package/dist/split-DK2k5eHf.js +0 -25
- package/dist/stack-DFatutCx.js +0 -27
- package/dist/sum-CJ0ULhmt.js +0 -27
- package/dist/tensor1d-vML0r3q6.js +0 -27
- package/dist/tensor2d-D76QGjF3.js +0 -30
- package/dist/tensor4d-Df1WlVDY.js +0 -30
- package/dist/webgpu_util-pLEV9tks.js +0 -80
- package/dist/zeros-Bj5rMYA7.js +0 -52
package/dist/data/textLoader.js
CHANGED
|
@@ -1,134 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { s as
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* you may not use this file except in compliance with the License.
|
|
10
|
-
* You may obtain a copy of the License at
|
|
11
|
-
*
|
|
12
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
* See the License for the specific language governing permissions and
|
|
18
|
-
* limitations under the License.
|
|
19
|
-
*
|
|
20
|
-
* =============================================================================
|
|
21
|
-
*/
|
|
22
|
-
function _(s, t) {
|
|
23
|
-
return b(s, t);
|
|
1
|
+
import { d as v, t as y } from "./index-ZyQhjEPo.js";
|
|
2
|
+
import { s as g } from "./index-CieiGp4Y.js";
|
|
3
|
+
import { D as S, T as h, e as N, x as R, a as k } from "./tensor-DdQUJZlz.js";
|
|
4
|
+
import { t as o, O as p } from "./tensor_util-DV-FP5Q3.js";
|
|
5
|
+
import { s as $ } from "./stack-yOIAalTq.js";
|
|
6
|
+
import { t as B } from "./tensor-f35l8Odg.js";
|
|
7
|
+
function _(r, t) {
|
|
8
|
+
return b(r, t);
|
|
24
9
|
}
|
|
25
|
-
function b(
|
|
26
|
-
if (
|
|
10
|
+
function b(r, t, e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set()) {
|
|
11
|
+
if (r == null)
|
|
27
12
|
return null;
|
|
28
|
-
if (typeof Blob == "function" &&
|
|
29
|
-
return
|
|
30
|
-
if (
|
|
13
|
+
if (typeof Blob == "function" && r instanceof Blob)
|
|
14
|
+
return r.slice();
|
|
15
|
+
if (s.has(r))
|
|
31
16
|
throw new Error("Circular references are not supported.");
|
|
32
|
-
if (e.has(
|
|
33
|
-
return e.get(
|
|
34
|
-
const n = t(
|
|
17
|
+
if (e.has(r))
|
|
18
|
+
return e.get(r);
|
|
19
|
+
const n = t(r);
|
|
35
20
|
if (n.recurse && n.value !== null)
|
|
36
21
|
throw new Error("A deep map function may not return both a value and recurse=true.");
|
|
37
22
|
if (n.recurse)
|
|
38
|
-
if (c(
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
for (const l in
|
|
42
|
-
const
|
|
43
|
-
|
|
23
|
+
if (c(r)) {
|
|
24
|
+
const i = Array.isArray(r) ? [] : {};
|
|
25
|
+
s.add(r);
|
|
26
|
+
for (const l in r) {
|
|
27
|
+
const m = r[l], d = b(m, t, e, s);
|
|
28
|
+
i[l] = d;
|
|
44
29
|
}
|
|
45
|
-
return
|
|
30
|
+
return s.delete(r), r.__proto__ && (i.__proto__ = r.__proto__), i;
|
|
46
31
|
} else
|
|
47
|
-
throw new Error(`Can't recurse into non-iterable type: ${
|
|
48
|
-
else return e.set(
|
|
32
|
+
throw new Error(`Can't recurse into non-iterable type: ${r}`);
|
|
33
|
+
else return e.set(r, n.value), n.value;
|
|
49
34
|
}
|
|
50
|
-
function P(
|
|
51
|
-
return E(
|
|
35
|
+
function P(r, t = I) {
|
|
36
|
+
return E(r, t);
|
|
52
37
|
}
|
|
53
|
-
function E(
|
|
54
|
-
const
|
|
55
|
-
if (e.has(
|
|
38
|
+
function E(r, t, e = /* @__PURE__ */ new Set()) {
|
|
39
|
+
const s = r[0];
|
|
40
|
+
if (e.has(s))
|
|
56
41
|
throw new Error("Circular references are not supported.");
|
|
57
|
-
const n = t(
|
|
42
|
+
const n = t(r);
|
|
58
43
|
if (n.recurse && n.value !== null)
|
|
59
44
|
throw new Error("A deep zip function may not return both a value and recurse=true.");
|
|
60
45
|
if (n.recurse)
|
|
61
|
-
if (c(
|
|
62
|
-
const
|
|
63
|
-
e.add(
|
|
64
|
-
for (const l in
|
|
65
|
-
const
|
|
66
|
-
|
|
46
|
+
if (c(s)) {
|
|
47
|
+
const i = Array.isArray(s) ? [] : {};
|
|
48
|
+
e.add(s);
|
|
49
|
+
for (const l in s) {
|
|
50
|
+
const m = r.map((F) => F[l]), d = E(m, t, e);
|
|
51
|
+
i[l] = d;
|
|
67
52
|
}
|
|
68
|
-
return e.delete(
|
|
53
|
+
return e.delete(s), i;
|
|
69
54
|
} else
|
|
70
|
-
throw new Error(`Can't recurse into non-iterable type: ${
|
|
55
|
+
throw new Error(`Can't recurse into non-iterable type: ${s}`);
|
|
71
56
|
else return n.value;
|
|
72
57
|
}
|
|
73
|
-
function I(
|
|
74
|
-
return
|
|
58
|
+
function I(r) {
|
|
59
|
+
return r === null ? null : c(r[0]) ? { value: null, recurse: !0 } : { value: r, recurse: !1 };
|
|
75
60
|
}
|
|
76
|
-
function c(
|
|
61
|
+
function c(r) {
|
|
77
62
|
let t = !1;
|
|
78
|
-
if (
|
|
79
|
-
t =
|
|
63
|
+
if (N().get("IS_BROWSER"))
|
|
64
|
+
t = r instanceof TextDecoder;
|
|
80
65
|
else {
|
|
81
66
|
const { StringDecoder: e } = require("string_decoder");
|
|
82
|
-
t =
|
|
67
|
+
t = r instanceof e;
|
|
83
68
|
}
|
|
84
|
-
return
|
|
69
|
+
return r != null && !ArrayBuffer.isView(r) && (Array.isArray(r) || typeof r == "object" && !(r instanceof h) && !(r instanceof Promise) && !t);
|
|
85
70
|
}
|
|
86
|
-
function M(
|
|
87
|
-
return
|
|
71
|
+
function M(r) {
|
|
72
|
+
return r == null || L(r) || Array.isArray(r) || typeof r == "object" && r instanceof h || S(r);
|
|
88
73
|
}
|
|
89
|
-
function L(
|
|
90
|
-
return
|
|
74
|
+
function L(r) {
|
|
75
|
+
return r === null || typeof r != "object" && typeof r != "function";
|
|
91
76
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
95
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
96
|
-
* you may not use this file except in compliance with the License.
|
|
97
|
-
* You may obtain a copy of the License at
|
|
98
|
-
*
|
|
99
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
100
|
-
*
|
|
101
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
102
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
103
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
104
|
-
* See the License for the specific language governing permissions and
|
|
105
|
-
* limitations under the License.
|
|
106
|
-
*
|
|
107
|
-
* =============================================================================
|
|
108
|
-
*/
|
|
109
|
-
function D(s) {
|
|
110
|
-
return _(s, O);
|
|
77
|
+
function D(r) {
|
|
78
|
+
return _(r, O);
|
|
111
79
|
}
|
|
112
|
-
function O(
|
|
113
|
-
return
|
|
80
|
+
function O(r) {
|
|
81
|
+
return r instanceof h ? { value: r.clone(), recurse: !1 } : c(r) ? { value: null, recurse: !0 } : { value: r, recurse: !1 };
|
|
114
82
|
}
|
|
115
|
-
/**
|
|
116
|
-
* @license
|
|
117
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
118
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
119
|
-
* you may not use this file except in compliance with the License.
|
|
120
|
-
* You may obtain a copy of the License at
|
|
121
|
-
*
|
|
122
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
123
|
-
*
|
|
124
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
125
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
126
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
127
|
-
* See the License for the specific language governing permissions and
|
|
128
|
-
* limitations under the License.
|
|
129
|
-
*
|
|
130
|
-
* =============================================================================
|
|
131
|
-
*/
|
|
132
83
|
class z {
|
|
133
84
|
/**
|
|
134
85
|
* Constructs a `RingBuffer`.
|
|
@@ -236,27 +187,10 @@ class z {
|
|
|
236
187
|
shuffleExcise(t) {
|
|
237
188
|
if (this.isEmpty())
|
|
238
189
|
throw new RangeError("Ring buffer is empty.");
|
|
239
|
-
const e = this.wrap(this.begin + t),
|
|
240
|
-
return this.set(e, this.pop()),
|
|
190
|
+
const e = this.wrap(this.begin + t), s = this.get(e);
|
|
191
|
+
return this.set(e, this.pop()), s;
|
|
241
192
|
}
|
|
242
193
|
}
|
|
243
|
-
/**
|
|
244
|
-
* @license
|
|
245
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
246
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
247
|
-
* you may not use this file except in compliance with the License.
|
|
248
|
-
* You may obtain a copy of the License at
|
|
249
|
-
*
|
|
250
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
251
|
-
*
|
|
252
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
253
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
254
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
255
|
-
* See the License for the specific language governing permissions and
|
|
256
|
-
* limitations under the License.
|
|
257
|
-
*
|
|
258
|
-
* =============================================================================
|
|
259
|
-
*/
|
|
260
194
|
class f extends z {
|
|
261
195
|
/**
|
|
262
196
|
* Constructs a `GrowingRingBuffer`.
|
|
@@ -277,40 +211,23 @@ class f extends z {
|
|
|
277
211
|
* Doubles the capacity of the buffer.
|
|
278
212
|
*/
|
|
279
213
|
expand() {
|
|
280
|
-
const t = this.capacity * 2, e = new Array(t),
|
|
281
|
-
for (let n = 0; n <
|
|
214
|
+
const t = this.capacity * 2, e = new Array(t), s = this.length();
|
|
215
|
+
for (let n = 0; n < s; n++)
|
|
282
216
|
e[n] = this.get(this.wrap(this.begin + n));
|
|
283
|
-
this.data = e, this.capacity = t, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end =
|
|
217
|
+
this.data = e, this.capacity = t, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end = s;
|
|
284
218
|
}
|
|
285
219
|
}
|
|
286
220
|
f.INITIAL_CAPACITY = 32;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
290
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
291
|
-
* you may not use this file except in compliance with the License.
|
|
292
|
-
* You may obtain a copy of the License at
|
|
293
|
-
*
|
|
294
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
295
|
-
*
|
|
296
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
297
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
298
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
299
|
-
* See the License for the specific language governing permissions and
|
|
300
|
-
* limitations under the License.
|
|
301
|
-
*
|
|
302
|
-
* =============================================================================
|
|
303
|
-
*/
|
|
304
|
-
function H(s) {
|
|
305
|
-
return new G(s);
|
|
221
|
+
function H(r) {
|
|
222
|
+
return new G(r);
|
|
306
223
|
}
|
|
307
|
-
function q(
|
|
308
|
-
return new W(
|
|
224
|
+
function q(r) {
|
|
225
|
+
return new W(r);
|
|
309
226
|
}
|
|
310
|
-
function Q(
|
|
311
|
-
return new A(
|
|
227
|
+
function Q(r, t) {
|
|
228
|
+
return new A(r, t);
|
|
312
229
|
}
|
|
313
|
-
class
|
|
230
|
+
class a {
|
|
314
231
|
/**
|
|
315
232
|
* Collect all remaining elements of a bounded stream into an array.
|
|
316
233
|
* Obviously this will succeed only for small streams that fit in memory.
|
|
@@ -339,9 +256,9 @@ class i {
|
|
|
339
256
|
*/
|
|
340
257
|
async toArrayForTest() {
|
|
341
258
|
const t = this.prefetch(100), e = [];
|
|
342
|
-
let
|
|
343
|
-
for (; !
|
|
344
|
-
e.push(
|
|
259
|
+
let s = await t.next();
|
|
260
|
+
for (; !s.done; )
|
|
261
|
+
e.push(s.value), s = await t.next();
|
|
345
262
|
return e;
|
|
346
263
|
}
|
|
347
264
|
/**
|
|
@@ -364,9 +281,9 @@ class i {
|
|
|
364
281
|
* fully processed.
|
|
365
282
|
*/
|
|
366
283
|
async resolveWhile(t) {
|
|
367
|
-
let e = await this.next(),
|
|
368
|
-
for (; !e.done &&
|
|
369
|
-
e = await this.next(),
|
|
284
|
+
let e = await this.next(), s = t(e.value);
|
|
285
|
+
for (; !e.done && s; )
|
|
286
|
+
e = await this.next(), s = t(e.value);
|
|
370
287
|
}
|
|
371
288
|
/**
|
|
372
289
|
* Handles errors thrown on this stream using a provided handler function.
|
|
@@ -510,8 +427,8 @@ class i {
|
|
|
510
427
|
* @returns A `LazyIterator` of batches of elements, represented as an object
|
|
511
428
|
* with collections at the leaves.
|
|
512
429
|
*/
|
|
513
|
-
columnMajorBatch(t, e = !0,
|
|
514
|
-
return this.rowMajorBatch(t, e).map((
|
|
430
|
+
columnMajorBatch(t, e = !0, s = I) {
|
|
431
|
+
return this.rowMajorBatch(t, e).map((i) => P(i, s));
|
|
515
432
|
}
|
|
516
433
|
/**
|
|
517
434
|
* Concatenate this `LazyIterator` with another.
|
|
@@ -577,7 +494,7 @@ class i {
|
|
|
577
494
|
return new U(this);
|
|
578
495
|
}
|
|
579
496
|
}
|
|
580
|
-
class G extends
|
|
497
|
+
class G extends a {
|
|
581
498
|
constructor(t) {
|
|
582
499
|
super(), this.items = t, this.trav = 0;
|
|
583
500
|
}
|
|
@@ -591,7 +508,7 @@ class G extends i {
|
|
|
591
508
|
return this.trav++, { value: D(t), done: !1 };
|
|
592
509
|
}
|
|
593
510
|
}
|
|
594
|
-
class W extends
|
|
511
|
+
class W extends a {
|
|
595
512
|
constructor(t) {
|
|
596
513
|
super(), this.nextFn = t;
|
|
597
514
|
}
|
|
@@ -606,7 +523,7 @@ class W extends i {
|
|
|
606
523
|
}
|
|
607
524
|
}
|
|
608
525
|
}
|
|
609
|
-
class U extends
|
|
526
|
+
class U extends a {
|
|
610
527
|
constructor(t) {
|
|
611
528
|
super(), this.upstream = t, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
612
529
|
}
|
|
@@ -620,7 +537,7 @@ class U extends i {
|
|
|
620
537
|
return this.upstream.next();
|
|
621
538
|
}
|
|
622
539
|
}
|
|
623
|
-
class Y extends
|
|
540
|
+
class Y extends a {
|
|
624
541
|
constructor(t, e) {
|
|
625
542
|
super(), this.upstream = t, this.maxCount = e, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
626
543
|
}
|
|
@@ -640,7 +557,7 @@ class Y extends i {
|
|
|
640
557
|
return this.upstream.next();
|
|
641
558
|
}
|
|
642
559
|
}
|
|
643
|
-
class J extends
|
|
560
|
+
class J extends a {
|
|
644
561
|
constructor(t, e) {
|
|
645
562
|
super(), this.upstream = t, this.maxCount = e, this.count = 0;
|
|
646
563
|
}
|
|
@@ -651,9 +568,9 @@ class J extends i {
|
|
|
651
568
|
return this.count++ >= this.maxCount ? { value: null, done: !0 } : this.upstream.next();
|
|
652
569
|
}
|
|
653
570
|
}
|
|
654
|
-
class V extends
|
|
655
|
-
constructor(t, e,
|
|
656
|
-
super(), this.upstream = t, this.batchSize = e, this.enableSmallLastBatch =
|
|
571
|
+
class V extends a {
|
|
572
|
+
constructor(t, e, s = !0) {
|
|
573
|
+
super(), this.upstream = t, this.batchSize = e, this.enableSmallLastBatch = s, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
657
574
|
}
|
|
658
575
|
summary() {
|
|
659
576
|
return `${this.upstream.summary()} -> RowMajorBatch`;
|
|
@@ -672,7 +589,7 @@ class V extends i {
|
|
|
672
589
|
return { value: t, done: !1 };
|
|
673
590
|
}
|
|
674
591
|
}
|
|
675
|
-
class X extends
|
|
592
|
+
class X extends a {
|
|
676
593
|
constructor(t, e) {
|
|
677
594
|
super(), this.upstream = t, this.predicate = e, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
678
595
|
}
|
|
@@ -691,7 +608,7 @@ class X extends i {
|
|
|
691
608
|
}
|
|
692
609
|
}
|
|
693
610
|
}
|
|
694
|
-
class K extends
|
|
611
|
+
class K extends a {
|
|
695
612
|
constructor(t, e) {
|
|
696
613
|
super(), this.upstream = t, this.transform = e;
|
|
697
614
|
}
|
|
@@ -702,13 +619,13 @@ class K extends i {
|
|
|
702
619
|
const t = await this.upstream.next();
|
|
703
620
|
if (t.done)
|
|
704
621
|
return { value: null, done: !0 };
|
|
705
|
-
const e = o(t.value),
|
|
706
|
-
for (const
|
|
707
|
-
p(
|
|
708
|
-
return { value:
|
|
622
|
+
const e = o(t.value), s = this.transform(t.value), n = o(s);
|
|
623
|
+
for (const i of e)
|
|
624
|
+
p(i, n) || i.dispose();
|
|
625
|
+
return { value: s, done: !1 };
|
|
709
626
|
}
|
|
710
627
|
}
|
|
711
|
-
class Z extends
|
|
628
|
+
class Z extends a {
|
|
712
629
|
constructor(t, e) {
|
|
713
630
|
super(), this.upstream = t, this.handler = e, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
714
631
|
}
|
|
@@ -728,7 +645,7 @@ class Z extends i {
|
|
|
728
645
|
}
|
|
729
646
|
}
|
|
730
647
|
}
|
|
731
|
-
class w extends
|
|
648
|
+
class w extends a {
|
|
732
649
|
constructor(t, e) {
|
|
733
650
|
super(), this.upstream = t, this.transform = e;
|
|
734
651
|
}
|
|
@@ -739,13 +656,13 @@ class w extends i {
|
|
|
739
656
|
const t = await this.upstream.next();
|
|
740
657
|
if (t.done)
|
|
741
658
|
return { value: null, done: !0 };
|
|
742
|
-
const e = o(t.value),
|
|
743
|
-
for (const
|
|
744
|
-
p(
|
|
745
|
-
return { value:
|
|
659
|
+
const e = o(t.value), s = await this.transform(t.value), n = o(s);
|
|
660
|
+
for (const i of e)
|
|
661
|
+
p(i, n) || i.dispose();
|
|
662
|
+
return { value: s, done: !1 };
|
|
746
663
|
}
|
|
747
664
|
}
|
|
748
|
-
class j extends
|
|
665
|
+
class j extends a {
|
|
749
666
|
constructor() {
|
|
750
667
|
super(), this.outputQueue = new f(), this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
751
668
|
}
|
|
@@ -770,14 +687,14 @@ class tt extends j {
|
|
|
770
687
|
const t = await this.upstream.next();
|
|
771
688
|
if (t.done)
|
|
772
689
|
return !1;
|
|
773
|
-
const e = o(t.value),
|
|
774
|
-
this.outputQueue.pushAll(
|
|
775
|
-
for (const
|
|
776
|
-
p(
|
|
690
|
+
const e = o(t.value), s = this.transform(t.value), n = o(s);
|
|
691
|
+
this.outputQueue.pushAll(s);
|
|
692
|
+
for (const i of e)
|
|
693
|
+
p(i, n) || i.dispose();
|
|
777
694
|
return !0;
|
|
778
695
|
}
|
|
779
696
|
}
|
|
780
|
-
class A extends
|
|
697
|
+
class A extends a {
|
|
781
698
|
constructor(t, e) {
|
|
782
699
|
super(), this.baseErrorHandler = e, this.lastRead = null, this.iterator = null, this.moreIterators = t;
|
|
783
700
|
}
|
|
@@ -789,20 +706,20 @@ class A extends i {
|
|
|
789
706
|
}
|
|
790
707
|
async readFromChain(t) {
|
|
791
708
|
if (await t, this.iterator == null) {
|
|
792
|
-
const
|
|
793
|
-
if (
|
|
709
|
+
const s = await this.moreIterators.next();
|
|
710
|
+
if (s.done)
|
|
794
711
|
return { value: null, done: !0 };
|
|
795
|
-
this.iterator =
|
|
712
|
+
this.iterator = s.value, this.baseErrorHandler != null && (this.iterator = this.iterator.handleErrors(this.baseErrorHandler));
|
|
796
713
|
}
|
|
797
714
|
const e = await this.iterator.next();
|
|
798
715
|
return e.done ? (this.iterator = null, this.readFromChain(t)) : e;
|
|
799
716
|
}
|
|
800
717
|
}
|
|
801
718
|
var x;
|
|
802
|
-
(function(
|
|
803
|
-
|
|
719
|
+
(function(r) {
|
|
720
|
+
r[r.FAIL = 0] = "FAIL", r[r.SHORTEST = 1] = "SHORTEST", r[r.LONGEST = 2] = "LONGEST";
|
|
804
721
|
})(x || (x = {}));
|
|
805
|
-
class C extends
|
|
722
|
+
class C extends a {
|
|
806
723
|
constructor(t, e) {
|
|
807
724
|
super(), this.upstream = t, this.bufferSize = e, this.buffer = new z(e);
|
|
808
725
|
}
|
|
@@ -824,8 +741,8 @@ class C extends i {
|
|
|
824
741
|
}
|
|
825
742
|
}
|
|
826
743
|
class et extends C {
|
|
827
|
-
constructor(t, e,
|
|
828
|
-
super(t, e), this.upstream = t, this.windowSize = e, this.upstreamExhausted = !1, this.random =
|
|
744
|
+
constructor(t, e, s) {
|
|
745
|
+
super(t, e), this.upstream = t, this.windowSize = e, this.upstreamExhausted = !1, this.random = g.alea(s || R().toString()), this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
829
746
|
}
|
|
830
747
|
async next() {
|
|
831
748
|
return this.lastRead = this.lastRead.then(() => this.serialNext()), this.lastRead;
|
|
@@ -847,23 +764,6 @@ class et extends C {
|
|
|
847
764
|
return { value: null, done: !0 };
|
|
848
765
|
}
|
|
849
766
|
}
|
|
850
|
-
/**
|
|
851
|
-
* @license
|
|
852
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
853
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
854
|
-
* you may not use this file except in compliance with the License.
|
|
855
|
-
* You may obtain a copy of the License at
|
|
856
|
-
*
|
|
857
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
858
|
-
*
|
|
859
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
860
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
861
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
862
|
-
* See the License for the specific language governing permissions and
|
|
863
|
-
* limitations under the License.
|
|
864
|
-
*
|
|
865
|
-
* =============================================================================
|
|
866
|
-
*/
|
|
867
767
|
class T {
|
|
868
768
|
constructor() {
|
|
869
769
|
this.size = null;
|
|
@@ -929,11 +829,11 @@ class T {
|
|
|
929
829
|
* @doc {heading: 'Data', subheading: 'Classes'}
|
|
930
830
|
*/
|
|
931
831
|
batch(t, e = !0) {
|
|
932
|
-
const
|
|
933
|
-
|
|
832
|
+
const s = this;
|
|
833
|
+
k(t > 0, () => `batchSize needs to be positive, but it is
|
|
934
834
|
${t}`);
|
|
935
835
|
let n;
|
|
936
|
-
return this.size === 1 / 0 || this.size == null ? n = this.size : e ? n = Math.ceil(this.size / t) : n = Math.floor(this.size / t), u(async () => (await
|
|
836
|
+
return this.size === 1 / 0 || this.size == null ? n = this.size : e ? n = Math.ceil(this.size / t) : n = Math.floor(this.size / t), u(async () => (await s.iterator()).columnMajorBatch(t, e, rt), n);
|
|
937
837
|
}
|
|
938
838
|
/**
|
|
939
839
|
* Concatenates this `Dataset` with another.
|
|
@@ -952,8 +852,8 @@ class T {
|
|
|
952
852
|
*/
|
|
953
853
|
concatenate(t) {
|
|
954
854
|
const e = this;
|
|
955
|
-
let
|
|
956
|
-
return this.size === 1 / 0 || t.size === 1 / 0 ?
|
|
855
|
+
let s;
|
|
856
|
+
return this.size === 1 / 0 || t.size === 1 / 0 ? s = 1 / 0 : this.size != null && t.size != null ? s = this.size + t.size : s = null, u(async () => (await e.iterator()).concatenate(await t.iterator()), s);
|
|
957
857
|
}
|
|
958
858
|
/**
|
|
959
859
|
* Filters this dataset according to `predicate`.
|
|
@@ -973,8 +873,8 @@ class T {
|
|
|
973
873
|
*/
|
|
974
874
|
filter(t) {
|
|
975
875
|
const e = this;
|
|
976
|
-
let
|
|
977
|
-
return this.size === 1 / 0 ?
|
|
876
|
+
let s;
|
|
877
|
+
return this.size === 1 / 0 ? s = 1 / 0 : s = null, u(async () => (await e.iterator()).filter((n) => y(() => t(n))), s);
|
|
978
878
|
}
|
|
979
879
|
/**
|
|
980
880
|
* Apply a function to every element of the dataset.
|
|
@@ -1012,7 +912,7 @@ class T {
|
|
|
1012
912
|
*/
|
|
1013
913
|
map(t) {
|
|
1014
914
|
const e = this;
|
|
1015
|
-
return u(async () => (await e.iterator()).map((
|
|
915
|
+
return u(async () => (await e.iterator()).map((s) => y(() => t(s))), this.size);
|
|
1016
916
|
}
|
|
1017
917
|
/**
|
|
1018
918
|
* Maps this dataset through an async 1-to-1 transform.
|
|
@@ -1076,11 +976,11 @@ class T {
|
|
|
1076
976
|
*/
|
|
1077
977
|
repeat(t) {
|
|
1078
978
|
const e = this;
|
|
1079
|
-
let
|
|
1080
|
-
return this.size != null && t > 0 ?
|
|
979
|
+
let s;
|
|
980
|
+
return this.size != null && t > 0 ? s = this.size * t : t === 0 ? s = 0 : this.size != null && (t === void 0 || t < 0) ? s = 1 / 0 : s = null, u(async () => {
|
|
1081
981
|
const n = q(async () => ({ value: await e.iterator(), done: !1 }));
|
|
1082
982
|
return Q(n.take(t));
|
|
1083
|
-
},
|
|
983
|
+
}, s);
|
|
1084
984
|
}
|
|
1085
985
|
/**
|
|
1086
986
|
* Creates a `Dataset` that skips `count` initial elements from this dataset.
|
|
@@ -1101,8 +1001,8 @@ class T {
|
|
|
1101
1001
|
*/
|
|
1102
1002
|
skip(t) {
|
|
1103
1003
|
const e = this;
|
|
1104
|
-
let
|
|
1105
|
-
return this.size != null && t >= 0 && this.size >= t ?
|
|
1004
|
+
let s;
|
|
1005
|
+
return this.size != null && t >= 0 && this.size >= t ? s = this.size - t : this.size != null && (this.size < t || t === void 0 || t < 0) ? s = 0 : s = null, u(async () => (await e.iterator()).skip(t), s);
|
|
1106
1006
|
}
|
|
1107
1007
|
/**
|
|
1108
1008
|
* Pseudorandomly shuffles the elements of this dataset. This is done in a
|
|
@@ -1125,13 +1025,13 @@ class T {
|
|
|
1125
1025
|
*
|
|
1126
1026
|
* @doc {heading: 'Data', subheading: 'Classes'}
|
|
1127
1027
|
*/
|
|
1128
|
-
shuffle(t, e,
|
|
1028
|
+
shuffle(t, e, s = !0) {
|
|
1129
1029
|
if (t == null || t < 0)
|
|
1130
1030
|
throw this.size == null ? new RangeError("`Dataset.shuffle()` requires bufferSize to be specified.") : new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);
|
|
1131
|
-
const n = this,
|
|
1031
|
+
const n = this, i = g.alea(e || R().toString());
|
|
1132
1032
|
return u(async () => {
|
|
1133
|
-
let l =
|
|
1134
|
-
return
|
|
1033
|
+
let l = i.int32();
|
|
1034
|
+
return s && (l += i.int32()), (await n.iterator()).shuffle(t, l.toString());
|
|
1135
1035
|
}, this.size);
|
|
1136
1036
|
}
|
|
1137
1037
|
/**
|
|
@@ -1153,8 +1053,8 @@ class T {
|
|
|
1153
1053
|
*/
|
|
1154
1054
|
take(t) {
|
|
1155
1055
|
const e = this;
|
|
1156
|
-
let
|
|
1157
|
-
return this.size != null && this.size > t ?
|
|
1056
|
+
let s;
|
|
1057
|
+
return this.size != null && this.size > t ? s = t : this.size != null && this.size <= t ? s = this.size : s = null, u(async () => (await e.iterator()).take(t), s);
|
|
1158
1058
|
}
|
|
1159
1059
|
/**
|
|
1160
1060
|
* Collect all elements of this dataset into an array.
|
|
@@ -1195,7 +1095,7 @@ class T {
|
|
|
1195
1095
|
}
|
|
1196
1096
|
}
|
|
1197
1097
|
T.MAX_BUFFER_SIZE = 1e4;
|
|
1198
|
-
function u(
|
|
1098
|
+
function u(r, t = null) {
|
|
1199
1099
|
return new class extends T {
|
|
1200
1100
|
constructor() {
|
|
1201
1101
|
super(...arguments), this.size = t;
|
|
@@ -1205,20 +1105,20 @@ function u(s, t = null) {
|
|
|
1205
1105
|
* from any underlying `Dataset`s.
|
|
1206
1106
|
*/
|
|
1207
1107
|
async iterator() {
|
|
1208
|
-
return
|
|
1108
|
+
return r();
|
|
1209
1109
|
}
|
|
1210
1110
|
}();
|
|
1211
1111
|
}
|
|
1212
|
-
function
|
|
1213
|
-
if (
|
|
1112
|
+
function rt(r) {
|
|
1113
|
+
if (r === null)
|
|
1214
1114
|
return null;
|
|
1215
|
-
const t =
|
|
1216
|
-
return M(t) ? { value:
|
|
1115
|
+
const t = r[0];
|
|
1116
|
+
return M(t) ? { value: st(r), recurse: !1 } : { value: null, recurse: !0 };
|
|
1217
1117
|
}
|
|
1218
|
-
function
|
|
1219
|
-
if (
|
|
1118
|
+
function st(r) {
|
|
1119
|
+
if (r.length === 0)
|
|
1220
1120
|
throw new Error("Can't make a batch of zero elements.");
|
|
1221
|
-
return
|
|
1121
|
+
return r[0] instanceof h ? $(r) : B(r);
|
|
1222
1122
|
}
|
|
1223
1123
|
export {
|
|
1224
1124
|
u as d,
|