mindspore 2.0.0a0__cp37-cp37m-win_amd64.whl → 2.0.0rc1__cp37-cp37m-win_amd64.whl
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.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/__init__.py +4 -2
- mindspore/_c_dataengine.cp37-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp37-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp37-win_amd64.pyd +0 -0
- mindspore/_check_jit_forbidden_api.py +102 -0
- mindspore/_checkparam.py +1066 -1001
- mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +4 -3
- mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +50 -48
- mindspore/_extends/parallel_compile/akg_compiler/util.py +9 -4
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +4 -4
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +9 -4
- mindspore/_extends/parse/__init__.py +5 -3
- mindspore/_extends/parse/namespace.py +16 -1
- mindspore/_extends/parse/parser.py +107 -22
- mindspore/_extends/parse/resources.py +0 -7
- mindspore/_extends/parse/standard_method.py +885 -413
- mindspore/amp.py +52 -57
- mindspore/boost/boost.py +2 -2
- mindspore/boost/boost_cell_wrapper.py +38 -20
- mindspore/boost/dim_reduce.py +3 -3
- mindspore/boost/group_loss_scale_manager.py +1 -1
- mindspore/common/__init__.py +4 -6
- mindspore/common/_decorator.py +2 -0
- mindspore/common/_register_for_adapter.py +55 -0
- mindspore/common/_stub_tensor.py +201 -0
- mindspore/common/_utils.py +41 -7
- mindspore/common/api.py +215 -141
- mindspore/common/dtype.py +8 -1
- mindspore/common/dump.py +2 -2
- mindspore/common/initializer.py +4 -2
- mindspore/common/jit_config.py +17 -13
- mindspore/common/mutable.py +33 -13
- mindspore/common/parameter.py +23 -21
- mindspore/common/seed.py +8 -24
- mindspore/common/sparse_tensor.py +62 -41
- mindspore/common/tensor.py +852 -1154
- mindspore/communication/__init__.py +2 -2
- mindspore/communication/_comm_helper.py +11 -4
- mindspore/communication/management.py +22 -21
- mindspore/config/op_info.config +501 -1008
- mindspore/context.py +201 -23
- mindspore/dataset/__init__.py +6 -6
- mindspore/dataset/audio/__init__.py +7 -7
- mindspore/dataset/audio/transforms.py +670 -30
- mindspore/dataset/audio/utils.py +47 -4
- mindspore/dataset/audio/validators.py +223 -1
- mindspore/dataset/callback/ds_callback.py +2 -2
- mindspore/dataset/core/config.py +210 -14
- mindspore/dataset/core/validator_helpers.py +2 -2
- mindspore/{parallel/nn/layers.py → dataset/debug/__init__.py} +7 -8
- mindspore/dataset/debug/debug_hook.py +65 -0
- mindspore/dataset/debug/pre_defined_hook.py +67 -0
- mindspore/dataset/engine/__init__.py +7 -3
- mindspore/dataset/engine/cache_client.py +1 -1
- mindspore/dataset/engine/datasets.py +322 -66
- mindspore/dataset/engine/datasets_audio.py +80 -76
- mindspore/dataset/engine/datasets_standard_format.py +51 -38
- mindspore/dataset/engine/datasets_text.py +232 -118
- mindspore/dataset/engine/datasets_user_defined.py +41 -17
- mindspore/dataset/engine/datasets_vision.py +746 -225
- mindspore/dataset/engine/graphdata.py +75 -10
- mindspore/dataset/engine/iterators.py +45 -5
- mindspore/dataset/engine/offload.py +48 -28
- mindspore/dataset/engine/validators.py +117 -8
- mindspore/dataset/text/__init__.py +6 -5
- mindspore/dataset/text/transforms.py +86 -3
- mindspore/dataset/text/utils.py +6 -4
- mindspore/dataset/text/validators.py +25 -0
- mindspore/dataset/transforms/__init__.py +3 -2
- mindspore/dataset/transforms/c_transforms.py +1 -1
- mindspore/dataset/transforms/transforms.py +2 -2
- mindspore/dataset/utils/__init__.py +2 -1
- mindspore/dataset/utils/line_reader.py +121 -0
- mindspore/dataset/vision/__init__.py +2 -3
- mindspore/dataset/vision/c_transforms.py +9 -9
- mindspore/dataset/vision/py_transforms.py +5 -5
- mindspore/dataset/vision/py_transforms_util.py +2 -0
- mindspore/dataset/vision/transforms.py +160 -161
- mindspore/dataset/vision/utils.py +3 -3
- mindspore/experimental/map_parameter.py +38 -26
- mindspore/include/OWNERS +0 -1
- mindspore/include/api/callback/callback.h +9 -13
- mindspore/include/api/callback/ckpt_saver.h +2 -2
- mindspore/include/api/callback/loss_monitor.h +2 -2
- mindspore/include/api/callback/lr_scheduler.h +5 -5
- mindspore/include/api/callback/time_monitor.h +2 -2
- mindspore/include/api/callback/train_accuracy.h +4 -6
- mindspore/include/api/cfg.h +19 -6
- mindspore/include/api/context.h +44 -9
- mindspore/include/api/delegate.h +1 -1
- mindspore/include/api/metrics/accuracy.h +2 -2
- mindspore/include/api/metrics/metrics.h +4 -3
- mindspore/include/api/model.h +9 -4
- mindspore/include/api/model_parallel_runner.h +2 -2
- mindspore/include/api/net.h +12 -11
- mindspore/include/api/serialization.h +19 -3
- mindspore/include/api/types.h +3 -3
- mindspore/include/dataset/constants.h +7 -0
- mindspore/include/dataset/text.h +59 -0
- mindspore/jpeg62.dll +0 -0
- mindspore/log.py +1 -1
- mindspore/mindrecord/filereader.py +18 -0
- mindspore/mindrecord/filewriter.py +197 -34
- mindspore/mindrecord/shardreader.py +9 -0
- mindspore/mindrecord/shardwriter.py +1 -1
- mindspore/mindrecord/tools/cifar100_to_mr.py +3 -3
- mindspore/mindrecord/tools/cifar10_to_mr.py +3 -3
- mindspore/mindrecord/tools/csv_to_mr.py +3 -3
- mindspore/mindrecord/tools/imagenet_to_mr.py +16 -11
- mindspore/mindrecord/tools/mnist_to_mr.py +2 -2
- mindspore/mindrecord/tools/tfrecord_to_mr.py +6 -6
- mindspore/mindspore_backend.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_shared_lib.dll +0 -0
- mindspore/nn/__init__.py +0 -4
- mindspore/nn/cell.py +204 -132
- mindspore/nn/dynamic_lr.py +1 -1
- mindspore/nn/grad/cell_grad.py +7 -6
- mindspore/nn/layer/__init__.py +5 -4
- mindspore/nn/layer/activation.py +40 -89
- mindspore/nn/layer/basic.py +255 -624
- mindspore/nn/layer/channel_shuffle.py +7 -6
- mindspore/nn/layer/combined.py +1 -1
- mindspore/nn/layer/container.py +41 -4
- mindspore/nn/layer/conv.py +64 -28
- mindspore/nn/layer/dense.py +9 -8
- mindspore/nn/layer/embedding.py +27 -25
- mindspore/nn/layer/image.py +53 -46
- mindspore/nn/layer/math.py +97 -105
- mindspore/nn/layer/normalization.py +117 -86
- mindspore/nn/layer/padding.py +185 -95
- mindspore/nn/layer/pooling.py +817 -414
- mindspore/nn/layer/rnn_cells.py +10 -15
- mindspore/nn/layer/rnns.py +37 -38
- mindspore/nn/layer/thor_layer.py +11 -12
- mindspore/nn/layer/timedistributed.py +5 -5
- mindspore/nn/layer/transformer.py +701 -0
- mindspore/nn/learning_rate_schedule.py +8 -8
- mindspore/nn/loss/__init__.py +5 -4
- mindspore/nn/loss/loss.py +334 -199
- mindspore/nn/optim/ada_grad.py +6 -6
- mindspore/nn/optim/adadelta.py +2 -3
- mindspore/nn/optim/adafactor.py +4 -5
- mindspore/nn/optim/adam.py +126 -62
- mindspore/nn/optim/adamax.py +3 -4
- mindspore/nn/optim/adasum.py +6 -6
- mindspore/nn/optim/asgd.py +2 -2
- mindspore/nn/optim/ftrl.py +67 -38
- mindspore/nn/optim/lamb.py +4 -5
- mindspore/nn/optim/lars.py +2 -2
- mindspore/nn/optim/lazyadam.py +43 -4
- mindspore/nn/optim/momentum.py +6 -5
- mindspore/nn/optim/optimizer.py +3 -1
- mindspore/nn/optim/proximal_ada_grad.py +2 -2
- mindspore/nn/optim/rmsprop.py +1 -1
- mindspore/nn/optim/rprop.py +8 -9
- mindspore/nn/optim/sgd.py +19 -13
- mindspore/nn/optim/thor.py +10 -15
- mindspore/nn/probability/__init__.py +0 -2
- mindspore/nn/probability/bijector/bijector.py +4 -4
- mindspore/nn/probability/bijector/invert.py +1 -1
- mindspore/nn/probability/bijector/softplus.py +2 -2
- mindspore/nn/probability/bnn_layers/dense_variational.py +1 -1
- mindspore/nn/probability/bnn_layers/layer_distribution.py +2 -2
- mindspore/nn/probability/distribution/_utils/utils.py +9 -15
- mindspore/nn/probability/distribution/bernoulli.py +3 -3
- mindspore/nn/probability/distribution/beta.py +1 -1
- mindspore/nn/probability/distribution/categorical.py +5 -7
- mindspore/nn/probability/distribution/cauchy.py +3 -3
- mindspore/nn/probability/distribution/distribution.py +2 -2
- mindspore/nn/probability/distribution/exponential.py +2 -2
- mindspore/nn/probability/distribution/gamma.py +3 -3
- mindspore/nn/probability/distribution/geometric.py +1 -1
- mindspore/nn/probability/distribution/gumbel.py +3 -3
- mindspore/nn/probability/distribution/half_normal.py +15 -11
- mindspore/nn/probability/distribution/laplace.py +16 -13
- mindspore/nn/probability/distribution/logistic.py +2 -2
- mindspore/nn/probability/distribution/normal.py +1 -1
- mindspore/nn/probability/distribution/poisson.py +1 -1
- mindspore/nn/probability/distribution/student_t.py +20 -15
- mindspore/nn/probability/distribution/transformed_distribution.py +4 -4
- mindspore/nn/probability/distribution/uniform.py +2 -2
- mindspore/nn/reinforcement/_tensors_queue.py +3 -3
- mindspore/nn/reinforcement/tensor_array.py +2 -2
- mindspore/nn/sparse/sparse.py +2 -2
- mindspore/nn/wrap/cell_wrapper.py +27 -10
- mindspore/nn/wrap/grad_reducer.py +2 -2
- mindspore/nn/wrap/loss_scale.py +40 -24
- mindspore/numpy/array_creations.py +33 -22
- mindspore/numpy/array_ops.py +35 -30
- mindspore/numpy/logic_ops.py +6 -27
- mindspore/numpy/math_ops.py +22 -19
- mindspore/numpy/utils.py +1 -1
- mindspore/numpy/utils_const.py +108 -58
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_constants.py +0 -6
- mindspore/ops/_grad/__init__.py +2 -1
- mindspore/ops/_grad/grad_array_ops.py +86 -117
- mindspore/ops/_grad/grad_base.py +23 -1
- mindspore/ops/_grad/grad_clip_ops.py +2 -3
- mindspore/ops/_grad/grad_comm_ops.py +34 -24
- mindspore/ops/_grad/grad_implementations.py +9 -45
- mindspore/ops/_grad/grad_inner_ops.py +47 -4
- mindspore/ops/_grad/grad_math_ops.py +142 -117
- mindspore/ops/_grad/grad_nn_ops.py +71 -165
- mindspore/ops/_grad/grad_sequence_ops.py +296 -0
- mindspore/ops/_grad/grad_sparse.py +7 -6
- mindspore/ops/_grad_experimental/__init__.py +1 -0
- mindspore/ops/_grad_experimental/grad_array_ops.py +150 -15
- mindspore/ops/_grad_experimental/grad_image_ops.py +16 -7
- mindspore/ops/_grad_experimental/grad_inner_ops.py +1 -22
- mindspore/ops/_grad_experimental/grad_linalg_ops.py +4 -11
- mindspore/ops/_grad_experimental/grad_math_ops.py +210 -89
- mindspore/ops/_grad_experimental/grad_nn_ops.py +26 -22
- mindspore/ops/_grad_experimental/grad_scalar_ops.py +112 -0
- mindspore/ops/_grad_experimental/grad_sparse_ops.py +49 -8
- mindspore/ops/_op_impl/_custom_op/batch_matmul_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold.py +2 -2
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold2.py +2 -2
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold2_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold2_grad_reduce.py +4 -4
- mindspore/ops/_op_impl/_custom_op/batchnorm_fold_grad.py +3 -3
- mindspore/ops/_op_impl/_custom_op/cholesky_trsm_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/correction_mul.py +2 -2
- mindspore/ops/_op_impl/_custom_op/correction_mul_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py +1 -5
- mindspore/ops/_op_impl/_custom_op/dsd_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perchannel.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perchannel_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perchannel_grad_reduce.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perlayer.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perlayer_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perlayer_grad_reduce.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_quant_perchannel.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_quant_perchannel_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_quant_perlayer.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fake_quant_perlayer_grad.py +2 -2
- mindspore/ops/_op_impl/_custom_op/fused_abs_max1_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/img2col_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_left_impl.py +2 -2
- mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_right_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_left_cast_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_right_mul_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/matmul_cube_impl.py +2 -2
- mindspore/ops/_op_impl/_custom_op/matmul_dds_impl.py +0 -4
- mindspore/ops/_op_impl/_custom_op/matrix_combine_impl.py +1 -1
- mindspore/ops/_op_impl/_custom_op/minmax_update_perchannel.py +2 -2
- mindspore/ops/_op_impl/_custom_op/minmax_update_perlayer.py +2 -2
- mindspore/ops/_op_impl/_custom_op/transpose02314_impl.py +1 -1
- mindspore/ops/_op_impl/aicpu/__init__.py +236 -4
- mindspore/ops/_op_impl/aicpu/abs.py +36 -0
- mindspore/ops/_op_impl/aicpu/{adaptive_avg_pool_2d_v1.py → adaptive_avg_pool_2d.py} +6 -5
- mindspore/ops/_op_impl/aicpu/adaptive_avg_pool_2d_grad.py +34 -0
- mindspore/ops/_op_impl/aicpu/add.py +43 -0
- mindspore/ops/_op_impl/aicpu/addcdiv.py +0 -32
- mindspore/ops/_op_impl/aicpu/addcmul.py +0 -84
- mindspore/ops/_op_impl/aicpu/affine_grid_grad.py +35 -0
- mindspore/ops/_op_impl/aicpu/batch_matmul.py +43 -43
- mindspore/ops/_op_impl/aicpu/bernoulli.py +48 -0
- mindspore/{compression/common/__init__.py → ops/_op_impl/aicpu/bessel_i0.py} +15 -8
- mindspore/ops/_op_impl/aicpu/channel_shuffle.py +40 -0
- mindspore/ops/_op_impl/aicpu/conj.py +11 -0
- mindspore/ops/_op_impl/aicpu/cumulative_logsumexp.py +0 -3
- mindspore/ops/_op_impl/aicpu/deformable_offsets.py +38 -0
- mindspore/ops/_op_impl/aicpu/deformable_offsets_grad.py +43 -0
- mindspore/ops/_op_impl/aicpu/{adaptive_avg_pool_2d_grad_v1.py → digamma.py} +7 -9
- mindspore/ops/_op_impl/aicpu/flatten.py +1 -0
- mindspore/ops/_op_impl/aicpu/fmax.py +36 -0
- mindspore/ops/_op_impl/aicpu/fmin.py +37 -0
- mindspore/ops/_op_impl/aicpu/fractional_max_pool3d_with_fixed_ksize.py +1 -1
- mindspore/ops/_op_impl/aicpu/fse_decode.py +43 -0
- mindspore/ops/_op_impl/aicpu/greater.py +41 -0
- mindspore/ops/_op_impl/aicpu/greater_equal.py +41 -0
- mindspore/ops/_op_impl/aicpu/index_put.py +50 -0
- mindspore/ops/_op_impl/aicpu/less.py +41 -0
- mindspore/{nn/probability/infer/variational/__init__.py → ops/_op_impl/aicpu/lgamma.py} +16 -10
- mindspore/ops/_op_impl/aicpu/mirror_pad.py +0 -4
- mindspore/ops/_op_impl/aicpu/mirror_pad_grad.py +0 -4
- mindspore/ops/_op_impl/aicpu/mul.py +3 -1
- mindspore/ops/_op_impl/aicpu/multinomial.py +14 -6
- mindspore/ops/_op_impl/aicpu/nllloss.py +38 -0
- mindspore/ops/_op_impl/aicpu/nllloss_grad.py +39 -0
- mindspore/ops/_op_impl/aicpu/ones_like.py +0 -2
- mindspore/ops/_op_impl/aicpu/polar.py +32 -0
- mindspore/ops/_op_impl/aicpu/polygamma.py +34 -0
- mindspore/ops/_op_impl/aicpu/quant_dtype_cast.py +40 -0
- mindspore/ops/_op_impl/aicpu/quantile.py +35 -0
- mindspore/ops/_op_impl/aicpu/ragged_tensor_to_sparse.py +73 -0
- mindspore/ops/_op_impl/aicpu/randperm_v2.py +41 -0
- mindspore/ops/_op_impl/aicpu/resize_bicubic.py +2 -8
- mindspore/ops/_op_impl/aicpu/resize_bicubic_grad.py +1 -1
- mindspore/ops/_op_impl/aicpu/resize_v2.py +68 -0
- mindspore/ops/_op_impl/aicpu/resize_v2_grad.py +68 -0
- mindspore/ops/_op_impl/aicpu/scatter_elements.py +4 -0
- mindspore/ops/_op_impl/aicpu/scatter_nd_update.py +2 -0
- mindspore/ops/_op_impl/aicpu/sequence_add.py +34 -0
- mindspore/ops/_op_impl/aicpu/sequence_add_offset.py +34 -0
- mindspore/ops/_op_impl/aicpu/sequence_addn.py +38 -0
- mindspore/ops/_op_impl/aicpu/smooth_l1_loss.py +35 -0
- mindspore/ops/_op_impl/aicpu/smooth_l1_loss_grad.py +37 -0
- mindspore/ops/_op_impl/aicpu/sparse_apply_adagrad_da.py +0 -24
- mindspore/ops/_op_impl/aicpu/sparse_cross.py +42 -0
- mindspore/ops/_op_impl/aicpu/sparse_slice.py +4 -0
- mindspore/ops/_op_impl/aicpu/sparse_slice_grad.py +6 -0
- mindspore/ops/_op_impl/aicpu/tensor_scatter_update.py +59 -0
- mindspore/ops/_op_impl/aicpu/trans_data.py +1 -0
- mindspore/ops/_op_impl/aicpu/tril_indices.py +34 -0
- mindspore/ops/_op_impl/aicpu/uniform.py +34 -0
- mindspore/ops/_op_impl/aicpu/uniform_candidate_sampler.py +1 -0
- mindspore/ops/_op_impl/aicpu/unique_consecutive.py +10 -2
- mindspore/ops/_op_impl/cpu/dynamic_shape.py +5 -1
- mindspore/ops/_op_impl/cpu/sparse_slice.py +4 -0
- mindspore/ops/_op_impl/cpu/sparse_slice_grad.py +6 -0
- mindspore/ops/_op_impl/cpu/tensor_shape.py +5 -1
- mindspore/ops/_op_impl/tbe/__init__.py +27 -611
- mindspore/ops/_op_impl/tbe/assign_add_ds.py +1 -0
- mindspore/ops/_op_impl/tbe/atomic_addr_clean.py +1 -1
- mindspore/ops/_op_impl/tbe/avg_pool_3d_grad.py +1 -1
- mindspore/ops/_op_impl/tbe/batch_matmul_ds.py +1 -0
- mindspore/ops/_op_impl/tbe/batch_to_space.py +1 -1
- mindspore/ops/_op_impl/tbe/batch_to_space_nd.py +1 -1
- mindspore/ops/_op_impl/tbe/bn_infer_grad.py +4 -2
- mindspore/ops/_op_impl/tbe/bn_training_update.py +0 -1
- mindspore/ops/_op_impl/tbe/bn_training_update_ds.py +0 -1
- mindspore/ops/_op_impl/tbe/broadcast_to_ds.py +6 -4
- mindspore/ops/_op_impl/tbe/cast.py +0 -2
- mindspore/ops/_op_impl/tbe/cast_ds.py +3 -3
- mindspore/ops/_op_impl/tbe/data_format_dim_map_ds.py +1 -0
- mindspore/ops/_op_impl/tbe/depthwise_conv2d.py +2 -2
- mindspore/ops/_op_impl/tbe/dynamic_atomic_addr_clean.py +1 -1
- mindspore/ops/_op_impl/tbe/gather_nd.py +1 -0
- mindspore/ops/_op_impl/tbe/{index_add.py → inplace_index_add.py} +3 -6
- mindspore/ops/_op_impl/tbe/matmul_ds.py +2 -0
- mindspore/ops/_op_impl/tbe/npu_clear_float_status_v2.py +35 -0
- mindspore/ops/_op_impl/tbe/npu_get_float_status_v2.py +35 -0
- mindspore/ops/_op_impl/tbe/scatter_mul.py +2 -0
- mindspore/ops/_op_impl/tbe/scatter_nd_add.py +0 -2
- mindspore/ops/_op_impl/tbe/space_to_batch.py +1 -1
- mindspore/ops/_op_impl/tbe/space_to_batch_nd.py +1 -1
- mindspore/ops/_op_impl/tbe/trans_data_ds.py +15 -5
- mindspore/ops/_register_for_op.py +1 -0
- mindspore/ops/_utils/__init__.py +1 -2
- mindspore/ops/_utils/utils.py +19 -40
- mindspore/ops/_vmap/vmap_array_ops.py +116 -38
- mindspore/ops/_vmap/vmap_base.py +16 -9
- mindspore/ops/_vmap/vmap_convolution_ops.py +7 -10
- mindspore/ops/_vmap/vmap_grad_math_ops.py +4 -4
- mindspore/ops/_vmap/vmap_grad_nn_ops.py +7 -5
- mindspore/ops/_vmap/vmap_image_ops.py +12 -5
- mindspore/ops/_vmap/vmap_math_ops.py +46 -5
- mindspore/ops/_vmap/vmap_nn_ops.py +15 -21
- mindspore/ops/_vmap/vmap_random_ops.py +1 -1
- mindspore/ops/bprop_mindir/AdaptiveAvgPool2D_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/AdaptiveMaxPool2D_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/AvgPool3D_bprop.mindir +150 -0
- mindspore/ops/bprop_mindir/AvgPool_bprop.mindir +66 -0
- mindspore/ops/bprop_mindir/BCEWithLogitsLoss_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/BatchNormGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/BiasAddGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/BinaryCrossEntropy_bprop.mindir +33 -0
- mindspore/ops/bprop_mindir/BroadcastTo_bprop.mindir +220 -106
- mindspore/ops/bprop_mindir/CTCLoss_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Conv2DBackpropFilter_bprop.mindir +240 -0
- mindspore/ops/bprop_mindir/Conv2DBackpropInput_bprop.mindir +247 -0
- mindspore/ops/bprop_mindir/Conv2DTranspose_bprop.mindir +247 -0
- mindspore/ops/bprop_mindir/Conv3DTranspose_bprop.mindir +315 -0
- mindspore/ops/bprop_mindir/Conv3D_bprop.mindir +278 -0
- mindspore/ops/bprop_mindir/DeformableOffsets_bprop.mindir +58 -0
- mindspore/ops/bprop_mindir/DepthwiseConv2dNative_bprop.mindir +138 -0
- mindspore/ops/bprop_mindir/Dropout2D_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Dropout3D_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DropoutDoMask_bprop.mindir +22 -23
- mindspore/ops/bprop_mindir/DropoutGenMask_bprop.mindir +16 -17
- mindspore/ops/bprop_mindir/DropoutGrad_bprop.mindir +27 -0
- mindspore/ops/bprop_mindir/Dropout_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DynamicGRUV2_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DynamicRNN_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Elu_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/EmbeddingLookup_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ExpandDims_bprop.mindir +39 -41
- mindspore/ops/bprop_mindir/FastGeLU_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/Flatten_bprop.mindir +41 -43
- mindspore/ops/bprop_mindir/GatherNd_bprop.mindir +51 -57
- mindspore/ops/bprop_mindir/Gather_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/HSigmoid_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/HSwish_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/InstanceNorm_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/KLDivLoss_bprop.mindir +126 -0
- mindspore/ops/bprop_mindir/L2Loss_bprop.mindir +15 -0
- mindspore/ops/bprop_mindir/L2Normalize_bprop.mindir +30 -0
- mindspore/ops/bprop_mindir/LRN_bprop.mindir +43 -0
- mindspore/ops/bprop_mindir/LayerNormGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/LogSoftmax_bprop.mindir +23 -0
- mindspore/ops/bprop_mindir/MaxPool3DGradGrad_bprop.mindir +74 -0
- mindspore/ops/bprop_mindir/MaxPool3DGrad_bprop.mindir +74 -0
- mindspore/ops/bprop_mindir/MaxPool3D_bprop.mindir +75 -0
- mindspore/ops/bprop_mindir/MaxPoolGradGrad_bprop.mindir +65 -0
- mindspore/ops/bprop_mindir/MaxPoolWithArgmax_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/MirrorPad_bprop.mindir +27 -0
- mindspore/ops/bprop_mindir/Mish_bprop.mindir +35 -0
- mindspore/ops/bprop_mindir/MulNoNan_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/NLLLoss_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/OneHot_bprop.mindir +24 -25
- mindspore/ops/bprop_mindir/PReLU_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Pad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Padding_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/RNNTLoss_bprop.mindir +29 -0
- mindspore/ops/bprop_mindir/ROIAlign_bprop.mindir +82 -0
- mindspore/ops/bprop_mindir/ReLU6_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/ReLUV2_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ReluGrad_bprop.mindir +18 -19
- mindspore/ops/bprop_mindir/Reshape_bprop.mindir +53 -53
- mindspore/ops/bprop_mindir/ResizeBilinear_bprop.mindir +29 -0
- mindspore/ops/bprop_mindir/ResizeNearestNeighbor_bprop.mindir +77 -85
- mindspore/ops/bprop_mindir/SeLU_bprop.mindir +21 -0
- mindspore/ops/bprop_mindir/SigmoidCrossEntropyWithLogits_bprop.mindir +21 -0
- mindspore/ops/bprop_mindir/SigmoidGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Sigmoid_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/SmoothL1Loss_bprop.mindir +36 -0
- mindspore/ops/bprop_mindir/SoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Softplus_bprop.mindir +16 -0
- mindspore/ops/bprop_mindir/Softsign_bprop.mindir +33 -0
- mindspore/ops/bprop_mindir/SparseSoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Squeeze_bprop.mindir +37 -39
- mindspore/ops/bprop_mindir/StridedSlice_bprop.mindir +70 -72
- mindspore/ops/bprop_mindir/TanhGrad_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Tanh_bprop.mindir +66 -0
- mindspore/ops/bprop_mindir/Tile_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TopK_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir +17 -17
- mindspore/ops/bprop_mindir/UpsampleNearest3D_bprop.mindir +32 -0
- mindspore/ops/bprop_mindir/UpsampleTrilinear3D_bprop.mindir +38 -0
- mindspore/ops/bprop_mindir/generate_mindir.py +2 -0
- mindspore/ops/composite/__init__.py +7 -8
- mindspore/ops/composite/base.py +101 -47
- mindspore/ops/composite/math_ops.py +188 -158
- mindspore/ops/composite/multitype_ops/_compile_utils.py +415 -170
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +142 -87
- mindspore/ops/composite/multitype_ops/add_impl.py +6 -1
- mindspore/ops/composite/multitype_ops/div_impl.py +2 -3
- mindspore/ops/composite/multitype_ops/getitem_impl.py +31 -3
- mindspore/ops/composite/multitype_ops/greater_equal_impl.py +31 -0
- mindspore/ops/composite/multitype_ops/greater_impl.py +31 -0
- mindspore/ops/composite/multitype_ops/in_impl.py +9 -0
- mindspore/ops/composite/multitype_ops/less_equal_impl.py +31 -0
- mindspore/ops/composite/multitype_ops/less_impl.py +31 -0
- mindspore/ops/composite/multitype_ops/mul_impl.py +21 -5
- mindspore/ops/composite/multitype_ops/not_in_impl.py +9 -0
- mindspore/ops/composite/multitype_ops/ones_like_impl.py +2 -4
- mindspore/ops/composite/multitype_ops/setitem_impl.py +21 -3
- mindspore/ops/composite/multitype_ops/sub_impl.py +1 -1
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +35 -4
- mindspore/ops/function/__init__.py +152 -8
- mindspore/ops/function/array_func.py +2555 -674
- mindspore/ops/function/clip_func.py +209 -13
- mindspore/ops/function/debug_func.py +2 -2
- mindspore/ops/function/grad/__init__.py +2 -1
- mindspore/ops/function/grad/grad_func.py +147 -62
- mindspore/ops/function/image_func.py +54 -38
- mindspore/ops/function/linalg_func.py +167 -16
- mindspore/ops/function/math_func.py +4849 -1492
- mindspore/ops/function/nn_func.py +2573 -988
- mindspore/ops/function/other_func.py +115 -0
- mindspore/ops/function/parameter_func.py +3 -3
- mindspore/ops/function/random_func.py +790 -73
- mindspore/ops/function/sparse_func.py +98 -78
- mindspore/ops/function/sparse_unary_func.py +54 -53
- mindspore/ops/function/spectral_func.py +27 -24
- mindspore/ops/function/vmap_func.py +22 -2
- mindspore/ops/functional.py +97 -37
- mindspore/ops/op_info_register.py +70 -28
- mindspore/ops/operations/__init__.py +47 -14
- mindspore/ops/operations/_csr_ops.py +7 -7
- mindspore/ops/operations/_embedding_cache_ops.py +5 -5
- mindspore/ops/operations/_grad_ops.py +276 -187
- mindspore/ops/operations/_inner_ops.py +319 -113
- mindspore/ops/operations/_ms_kernel.py +10 -8
- mindspore/ops/operations/_ocr_ops.py +9 -9
- mindspore/ops/operations/_opaque_predicate_registry.py +4 -0
- mindspore/ops/operations/_quant_ops.py +137 -102
- mindspore/ops/operations/_rl_inner_ops.py +121 -60
- mindspore/ops/operations/_scalar_ops.py +466 -0
- mindspore/ops/operations/_sequence_ops.py +1004 -2
- mindspore/ops/operations/_tensor_array.py +10 -11
- mindspore/ops/operations/_thor_ops.py +1 -1
- mindspore/ops/operations/array_ops.py +801 -466
- mindspore/ops/operations/comm_ops.py +51 -49
- mindspore/ops/operations/control_ops.py +2 -2
- mindspore/ops/operations/custom_ops.py +123 -44
- mindspore/ops/operations/debug_ops.py +24 -24
- mindspore/ops/operations/image_ops.py +240 -153
- mindspore/ops/operations/inner_ops.py +34 -50
- mindspore/ops/operations/linalg_ops.py +31 -9
- mindspore/ops/operations/math_ops.py +988 -757
- mindspore/ops/operations/nn_ops.py +965 -819
- mindspore/ops/operations/other_ops.py +51 -40
- mindspore/ops/operations/random_ops.py +204 -122
- mindspore/ops/operations/rl_ops.py +8 -9
- mindspore/ops/operations/sparse_ops.py +254 -93
- mindspore/ops/operations/spectral_ops.py +35 -3
- mindspore/ops/primitive.py +111 -9
- mindspore/parallel/_auto_parallel_context.py +189 -83
- mindspore/parallel/_offload_context.py +185 -0
- mindspore/parallel/_parallel_serialization.py +99 -7
- mindspore/parallel/_ps_context.py +9 -5
- mindspore/parallel/_recovery_context.py +1 -1
- mindspore/parallel/_tensor.py +7 -1
- mindspore/{nn/transformer → parallel/_transformer}/__init__.py +6 -6
- mindspore/{nn/transformer → parallel/_transformer}/layers.py +6 -37
- mindspore/{nn/transformer → parallel/_transformer}/loss.py +4 -7
- mindspore/{nn/transformer → parallel/_transformer}/moe.py +20 -16
- mindspore/{nn/transformer → parallel/_transformer}/op_parallel_config.py +3 -3
- mindspore/{nn/transformer → parallel/_transformer}/transformer.py +48 -111
- mindspore/parallel/_utils.py +1 -2
- mindspore/parallel/algo_parameter_config.py +1 -1
- mindspore/parallel/checkpoint_transform.py +37 -34
- mindspore/parallel/shard.py +17 -18
- mindspore/profiler/common/validator/validate_path.py +2 -2
- mindspore/profiler/envprofiling.py +69 -47
- mindspore/profiler/parser/ascend_timeline_generator.py +49 -42
- mindspore/profiler/parser/base_timeline_generator.py +49 -56
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +98 -78
- mindspore/profiler/parser/hwts_log_parser.py +1 -1
- mindspore/profiler/parser/integrator.py +15 -14
- mindspore/profiler/parser/minddata_analyzer.py +2 -2
- mindspore/profiler/parser/msadvisor_analyzer.py +12 -25
- mindspore/profiler/parser/msadvisor_parser.py +2 -4
- mindspore/profiler/parser/optime_parser.py +17 -18
- mindspore/profiler/parser/profiler_info.py +2 -1
- mindspore/profiler/profiling.py +218 -186
- mindspore/rewrite/__init__.py +3 -1
- mindspore/rewrite/api/node.py +1 -114
- mindspore/rewrite/api/node_type.py +3 -0
- mindspore/rewrite/api/pattern_engine.py +31 -1
- mindspore/rewrite/api/scoped_value.py +4 -4
- mindspore/rewrite/api/symbol_tree.py +3 -78
- mindspore/rewrite/api/tree_node_helper.py +1 -1
- mindspore/rewrite/ast_creator_register.py +1 -0
- mindspore/rewrite/ast_helpers/__init__.py +2 -2
- mindspore/rewrite/ast_helpers/ast_creator.py +1 -2
- mindspore/rewrite/ast_helpers/ast_finder.py +65 -0
- mindspore/rewrite/ast_helpers/ast_modifier.py +11 -3
- mindspore/rewrite/ast_transformers/flatten_recursive_stmt.py +18 -2
- mindspore/rewrite/namespace.py +0 -2
- mindspore/rewrite/node.py +157 -11
- mindspore/rewrite/parsers/assign_parser.py +231 -53
- mindspore/rewrite/parsers/class_def_parser.py +187 -109
- mindspore/rewrite/parsers/for_parser.py +24 -14
- mindspore/rewrite/parsers/function_def_parser.py +21 -4
- mindspore/rewrite/parsers/if_parser.py +6 -2
- mindspore/rewrite/sparsify/__init__.py +0 -0
- mindspore/rewrite/sparsify/sparse_transformer.py +448 -0
- mindspore/rewrite/sparsify/sparsify.py +109 -0
- mindspore/rewrite/sparsify/utils.py +173 -0
- mindspore/rewrite/symbol_tree.py +256 -133
- mindspore/rewrite/symbol_tree_builder.py +38 -1
- mindspore/run_check/_check_version.py +69 -63
- mindspore/run_check/run_check.py +2 -1
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/__init__.py +1 -1
- mindspore/train/_utils.py +28 -5
- mindspore/train/amp.py +273 -102
- mindspore/train/callback/_backup_and_restore.py +5 -5
- mindspore/train/callback/_callback.py +2 -2
- mindspore/train/callback/_checkpoint.py +3 -3
- mindspore/train/callback/_early_stop.py +3 -3
- mindspore/train/callback/_lambda_callback.py +2 -2
- mindspore/train/callback/_landscape.py +29 -31
- mindspore/train/callback/_loss_monitor.py +3 -3
- mindspore/train/callback/_on_request_exit.py +3 -3
- mindspore/train/callback/_reduce_lr_on_plateau.py +4 -4
- mindspore/train/callback/_summary_collector.py +23 -16
- mindspore/train/callback/_time_monitor.py +3 -3
- mindspore/train/checkpoint_pb2.py +68 -8
- mindspore/train/data_sink.py +15 -3
- mindspore/train/dataset_helper.py +10 -15
- mindspore/train/loss_scale_manager.py +8 -11
- mindspore/train/metrics/__init__.py +1 -1
- mindspore/train/metrics/bleu_score.py +1 -1
- mindspore/train/metrics/confusion_matrix.py +1 -1
- mindspore/train/metrics/cosine_similarity.py +1 -1
- mindspore/train/metrics/dice.py +2 -2
- mindspore/train/metrics/fbeta.py +1 -1
- mindspore/train/metrics/hausdorff_distance.py +4 -3
- mindspore/train/metrics/mean_surface_distance.py +2 -2
- mindspore/train/metrics/occlusion_sensitivity.py +1 -1
- mindspore/train/metrics/perplexity.py +1 -1
- mindspore/train/metrics/precision.py +1 -1
- mindspore/train/metrics/recall.py +1 -1
- mindspore/train/metrics/roc.py +2 -2
- mindspore/train/metrics/root_mean_square_surface_distance.py +2 -2
- mindspore/train/mind_ir_pb2.py +116 -37
- mindspore/train/model.py +45 -28
- mindspore/train/serialization.py +295 -188
- mindspore/train/summary/_summary_adapter.py +1 -1
- mindspore/train/summary/summary_record.py +43 -13
- mindspore/train/train_thor/convert_utils.py +2 -2
- mindspore/train/train_thor/dataset_helper.py +3 -3
- mindspore/turbojpeg.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.0.0a0.dist-info → mindspore-2.0.0rc1.dist-info}/METADATA +3 -2
- {mindspore-2.0.0a0.dist-info → mindspore-2.0.0rc1.dist-info}/RECORD +610 -541
- mindspore/compression/__init__.py +0 -19
- mindspore/compression/common/constant.py +0 -124
- mindspore/compression/export/__init__.py +0 -19
- mindspore/compression/export/quant_export.py +0 -515
- mindspore/compression/quant/__init__.py +0 -28
- mindspore/compression/quant/qat.py +0 -634
- mindspore/compression/quant/quant_utils.py +0 -462
- mindspore/compression/quant/quantizer.py +0 -68
- mindspore/nn/layer/quant.py +0 -1868
- mindspore/nn/layer/rnn_utils.py +0 -90
- mindspore/nn/probability/dpn/__init__.py +0 -22
- mindspore/nn/probability/dpn/vae/__init__.py +0 -25
- mindspore/nn/probability/dpn/vae/cvae.py +0 -140
- mindspore/nn/probability/dpn/vae/vae.py +0 -124
- mindspore/nn/probability/infer/__init__.py +0 -22
- mindspore/nn/probability/infer/variational/elbo.py +0 -70
- mindspore/nn/probability/infer/variational/svi.py +0 -84
- mindspore/nn/probability/toolbox/__init__.py +0 -22
- mindspore/nn/probability/toolbox/anomaly_detection.py +0 -99
- mindspore/nn/probability/toolbox/uncertainty_evaluation.py +0 -364
- mindspore/nn/probability/transforms/__init__.py +0 -22
- mindspore/nn/probability/transforms/transform_bnn.py +0 -262
- mindspore/nn/probability/zhusuan/__init__.py +0 -18
- mindspore/nn/probability/zhusuan/framework/__init__.py +0 -18
- mindspore/nn/probability/zhusuan/framework/bn.py +0 -95
- mindspore/nn/probability/zhusuan/variational/__init__.py +0 -18
- mindspore/nn/probability/zhusuan/variational/elbo.py +0 -46
- mindspore/ops/_op_impl/aicpu/parallel_concat.py +0 -42
- mindspore/ops/_op_impl/tbe/gather_v2.py +0 -56
- mindspore/ops/bprop_mindir/AssignAdd_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/Cast_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/LogicalOr_bprop.mindir +0 -19
- mindspore/ops/bprop_mindir/MatMul_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ReLU_bprop.mindir +0 -17
- mindspore/ops/bprop_mindir/Transpose_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/UpdateState_bprop.mindir +0 -15
- mindspore/ops/composite/array_ops.py +0 -241
- mindspore/ops/composite/clip_ops.py +0 -134
- mindspore/ops/composite/random_ops.py +0 -426
- mindspore/ops/composite/vmap_ops.py +0 -38
- mindspore/parallel/nn/__init__.py +0 -42
- mindspore/parallel/nn/loss.py +0 -22
- mindspore/parallel/nn/moe.py +0 -21
- mindspore/parallel/nn/op_parallel_config.py +0 -22
- mindspore/parallel/nn/transformer.py +0 -31
- {mindspore-2.0.0a0.dist-info → mindspore-2.0.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-2.0.0a0.dist-info → mindspore-2.0.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.0.0a0.dist-info → mindspore-2.0.0rc1.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2022 Huawei Technologies Co., Ltd
|
|
1
|
+
# Copyright 2022-2023 Huawei Technologies Co., Ltd
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -31,6 +31,7 @@ import json
|
|
|
31
31
|
import os
|
|
32
32
|
import signal
|
|
33
33
|
import stat
|
|
34
|
+
import warnings
|
|
34
35
|
|
|
35
36
|
import gc
|
|
36
37
|
import time
|
|
@@ -59,6 +60,7 @@ import mindspore.dataset.transforms.py_transforms as py_transforms
|
|
|
59
60
|
import mindspore.dataset.transforms as transforms
|
|
60
61
|
from mindspore.dataset.text.utils import SentencePieceModel, DE_C_INTER_SENTENCEPIECE_MODE
|
|
61
62
|
from mindspore.parallel._utils import _get_device_num
|
|
63
|
+
from mindspore.dataset.debug import DebugHook
|
|
62
64
|
|
|
63
65
|
from . import samplers
|
|
64
66
|
from .iterators import DictIterator, TupleIterator, DummyIterator, check_iterator_cleanup, _set_iterator_cleanup, \
|
|
@@ -69,7 +71,7 @@ from .validators import check_batch, check_shuffle, check_map, check_filter, che
|
|
|
69
71
|
check_sync_wait, check_zip_dataset, check_add_column, check_concat, check_split, check_bucket_batch_by_length, \
|
|
70
72
|
check_save, check_tuple_iterator, check_dict_iterator, check_schema, check_to_device_send, check_padded_batch
|
|
71
73
|
from ..core.config import get_callback_timeout, _init_device_info, get_enable_shared_mem, get_num_parallel_workers, \
|
|
72
|
-
get_enable_watchdog, get_seed, set_seed
|
|
74
|
+
get_enable_watchdog, get_seed, set_seed, get_debug_mode, get_multiprocessing_timeout_interval, _get_debug_hook_list
|
|
73
75
|
from ..core.datatypes import mstype_to_detype
|
|
74
76
|
from ..core.validator_helpers import replace_none
|
|
75
77
|
from ..core.py_util_helpers import ExceptionHandler
|
|
@@ -114,17 +116,19 @@ def _get_training_dataset():
|
|
|
114
116
|
return _train_dataset
|
|
115
117
|
|
|
116
118
|
|
|
117
|
-
def _reset_training_dataset(
|
|
119
|
+
def _reset_training_dataset(global_step, dataset_size):
|
|
118
120
|
"""
|
|
119
|
-
Reset the training dataset to the given step
|
|
121
|
+
Reset the training dataset to the given global step.
|
|
120
122
|
|
|
121
123
|
Args:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
global_step (int): Number of global steps that have completed training.
|
|
125
|
+
Dataset will provide data from its next step after reset.
|
|
126
|
+
dataset_size (int): Number of steps per epoch.
|
|
124
127
|
"""
|
|
125
128
|
dataset = _get_training_dataset()
|
|
126
129
|
if dataset is not None:
|
|
127
|
-
|
|
130
|
+
epoch = global_step // dataset_size
|
|
131
|
+
dataset._reset(global_step, epoch) # pylint: disable=protected-access
|
|
128
132
|
else:
|
|
129
133
|
raise RuntimeError("Training dataset is not set.")
|
|
130
134
|
|
|
@@ -450,6 +454,9 @@ class Dataset:
|
|
|
450
454
|
|
|
451
455
|
Returns:
|
|
452
456
|
str, JSON string of the pipeline.
|
|
457
|
+
|
|
458
|
+
Examples:
|
|
459
|
+
>>> dataset_json = dataset.to_json("/path/to/mnist_dataset_pipeline.json")
|
|
453
460
|
"""
|
|
454
461
|
ir_tree, _ = self.create_ir_tree()
|
|
455
462
|
return json.loads(ir_tree.to_json(filename))
|
|
@@ -490,17 +497,17 @@ class Dataset:
|
|
|
490
497
|
specified, then that column will be padded to the longest in the current
|
|
491
498
|
batch, and 0 will be used as the padding value. Any None dimensions will
|
|
492
499
|
be padded to the longest in the current batch, unless if
|
|
493
|
-
pad_to_bucket_boundary is True. If no padding is wanted, set pad_info
|
|
500
|
+
`pad_to_bucket_boundary` is True. If no padding is wanted, set pad_info
|
|
494
501
|
to None. Default: None.
|
|
495
502
|
pad_to_bucket_boundary (bool, optional): If True, will pad each None
|
|
496
|
-
dimension in pad_info to the bucket_boundary minus 1. If there are any
|
|
503
|
+
dimension in `pad_info` to the bucket_boundary minus 1. If there are any
|
|
497
504
|
elements that fall into the last bucket, an error will occur.
|
|
498
505
|
Default: False.
|
|
499
506
|
drop_remainder (bool, optional): If True, will drop the last batch for each
|
|
500
507
|
bucket if it is not a full batch. Default: False.
|
|
501
508
|
|
|
502
509
|
Returns:
|
|
503
|
-
Dataset, dataset
|
|
510
|
+
Dataset, dataset bucketized and batched by length.
|
|
504
511
|
|
|
505
512
|
Examples:
|
|
506
513
|
>>> # Create a dataset where certain counts rows are combined into a batch
|
|
@@ -571,9 +578,11 @@ class Dataset:
|
|
|
571
578
|
columns of the last operation. Default: None, output columns will have the same
|
|
572
579
|
name as the input columns, i.e., the columns will be replaced.
|
|
573
580
|
|
|
574
|
-
- python_multiprocessing (bool, optional): Parallelize Python function per_batch_map with
|
|
575
|
-
multi-processing
|
|
576
|
-
|
|
581
|
+
- python_multiprocessing (bool, optional): Parallelize Python function `per_batch_map` with
|
|
582
|
+
multi-processing or multi-threading mode, True means multi-processing, False means multi-threading
|
|
583
|
+
If `per_batch_map` is a I/O bound task, use multi-threading mode.
|
|
584
|
+
If `per_batch_map` is a CPU bound task, it is recommended to use multi-processing mode.
|
|
585
|
+
Default: False, use python multi-threading mode.
|
|
577
586
|
|
|
578
587
|
- max_rowsize(int, optional): Maximum size of row in MB that is used for shared memory allocation to
|
|
579
588
|
copy data between processes. This is only used if python_multiprocessing is set to True. Default: 16.
|
|
@@ -586,7 +595,7 @@ class Dataset:
|
|
|
586
595
|
>>> # and drops the last incomplete batch if there is one.
|
|
587
596
|
>>> dataset = dataset.batch(100, True)
|
|
588
597
|
>>>
|
|
589
|
-
>>> # 2
|
|
598
|
+
>>> # 2) resize image according to its batch number, if it's 5-th batch, resize to (5^2, 5^2) = (25, 25)
|
|
590
599
|
>>> def np_resize(col, BatchInfo):
|
|
591
600
|
... output = col.copy()
|
|
592
601
|
... s = (BatchInfo.get_batch_num() + 1) ** 2
|
|
@@ -599,7 +608,7 @@ class Dataset:
|
|
|
599
608
|
... return (output,)
|
|
600
609
|
>>> dataset = dataset.batch(batch_size=8, input_columns=["image"], per_batch_map=np_resize)
|
|
601
610
|
>>>
|
|
602
|
-
>>> # 3
|
|
611
|
+
>>> # 3) Create a dataset where its batch size is dynamic
|
|
603
612
|
>>> # Define a callable batch size function and let batch size increase 1 each time.
|
|
604
613
|
>>> def add_one(BatchInfo):
|
|
605
614
|
... return BatchInfo.get_batch_num() + 1
|
|
@@ -650,7 +659,7 @@ class Dataset:
|
|
|
650
659
|
>>> # and drops the last incomplete batch if there is one.
|
|
651
660
|
>>> dataset = dataset.padded_batch(100, True)
|
|
652
661
|
>>>
|
|
653
|
-
>>> # 3
|
|
662
|
+
>>> # 3) Create a dataset where its batch size is dynamic
|
|
654
663
|
>>> # Define a callable batch size function and let batch size increase 1 each time.
|
|
655
664
|
>>> def add_one(BatchInfo):
|
|
656
665
|
... return BatchInfo.get_batch_num() + 1
|
|
@@ -811,11 +820,11 @@ class Dataset:
|
|
|
811
820
|
`output_columns` , and if not specified, the column name of output column is same as that of `input_columns` .
|
|
812
821
|
|
|
813
822
|
- If you use transformations (
|
|
814
|
-
`vision transform <https://mindspore.cn/docs/en/r2.0
|
|
823
|
+
`vision transform <https://mindspore.cn/docs/en/r2.0/api_python/mindspore.\
|
|
815
824
|
dataset.transforms.html#module-mindspore.dataset.vision>`_ ,
|
|
816
|
-
`nlp transform <https://mindspore.cn/docs/en/r2.0
|
|
825
|
+
`nlp transform <https://mindspore.cn/docs/en/r2.0/api_python/mindspore.\
|
|
817
826
|
dataset.transforms.html#module-mindspore.dataset.text>`_ ,
|
|
818
|
-
`audio transform <https://mindspore.cn/docs/en/r2.0
|
|
827
|
+
`audio transform <https://mindspore.cn/docs/en/r2.0/api_python/mindspore.\
|
|
819
828
|
dataset.transforms.html#module-mindspore.dataset.audio>`_ )
|
|
820
829
|
provided by mindspore dataset, please use the following parameters:
|
|
821
830
|
|
|
@@ -1316,6 +1325,16 @@ class Dataset:
|
|
|
1316
1325
|
|
|
1317
1326
|
Returns:
|
|
1318
1327
|
Dataset, dataset for transferring.
|
|
1328
|
+
|
|
1329
|
+
Examples:
|
|
1330
|
+
>>> import time
|
|
1331
|
+
>>>
|
|
1332
|
+
>>> data = ds.TFRecordDataset('/path/to/TF_FILES', '/path/to/TF_SCHEMA_FILE', shuffle=ds.Shuffle.FILES)
|
|
1333
|
+
>>>
|
|
1334
|
+
>>> data = data.device_que()
|
|
1335
|
+
>>> data.send()
|
|
1336
|
+
>>> time.sleep(0.1)
|
|
1337
|
+
>>> data.stop_send()
|
|
1319
1338
|
"""
|
|
1320
1339
|
return TransferDataset(self, send_epoch_end, create_data_info_queue)
|
|
1321
1340
|
|
|
@@ -1389,6 +1408,17 @@ class Dataset:
|
|
|
1389
1408
|
num_files (int, optional): Number of dataset files. Default: 1.
|
|
1390
1409
|
file_type (str, optional): Dataset format. Default: 'mindrecord'.
|
|
1391
1410
|
|
|
1411
|
+
Examples:
|
|
1412
|
+
>>> import numpy as np
|
|
1413
|
+
>>>
|
|
1414
|
+
>>> def generator_1d():
|
|
1415
|
+
... for i in range(10):
|
|
1416
|
+
... yield (np.array([i]),)
|
|
1417
|
+
>>>
|
|
1418
|
+
>>>
|
|
1419
|
+
>>> # apply dataset operations
|
|
1420
|
+
>>> d1 = ds.GeneratorDataset(generator_1d, ["data"], shuffle=False)
|
|
1421
|
+
>>> d1.save('/path/to/save_file')
|
|
1392
1422
|
"""
|
|
1393
1423
|
ir_tree, api_tree = self.create_ir_tree()
|
|
1394
1424
|
|
|
@@ -1417,7 +1447,7 @@ class Dataset:
|
|
|
1417
1447
|
Default: -1, iterator can be iterated infinite number of epochs.
|
|
1418
1448
|
output_numpy (bool, optional): Whether or not to output NumPy datatype.
|
|
1419
1449
|
If output_numpy=False, iterator will output MSTensor. Default: False.
|
|
1420
|
-
do_copy (bool, optional):
|
|
1450
|
+
do_copy (bool, optional): When output data type is mindspore.Tensor,
|
|
1421
1451
|
use this param to select the conversion method, only take False for better performance. Default: True.
|
|
1422
1452
|
|
|
1423
1453
|
Returns:
|
|
@@ -1440,7 +1470,7 @@ class Dataset:
|
|
|
1440
1470
|
return TupleIterator(self, columns, num_epochs, output_numpy, do_copy)
|
|
1441
1471
|
|
|
1442
1472
|
@check_dict_iterator
|
|
1443
|
-
def create_dict_iterator(self, num_epochs=-1, output_numpy=False):
|
|
1473
|
+
def create_dict_iterator(self, num_epochs=-1, output_numpy=False, do_copy=True):
|
|
1444
1474
|
"""
|
|
1445
1475
|
Create an iterator over the dataset. The data retrieved will be a dictionary datatype.
|
|
1446
1476
|
|
|
@@ -1449,6 +1479,8 @@ class Dataset:
|
|
|
1449
1479
|
Default: -1, iterator can be iterated infinite number of epochs.
|
|
1450
1480
|
output_numpy (bool, optional): Whether or not to output NumPy datatype,
|
|
1451
1481
|
if output_numpy=False, iterator will output MSTensor. Default: False.
|
|
1482
|
+
do_copy (bool, optional): When output data type is mindspore.Tensor,
|
|
1483
|
+
use this param to select the conversion method, only take False for better performance. Default: True.
|
|
1452
1484
|
|
|
1453
1485
|
Returns:
|
|
1454
1486
|
Iterator, dictionary iterator over the dataset.
|
|
@@ -1467,7 +1499,7 @@ class Dataset:
|
|
|
1467
1499
|
|
|
1468
1500
|
if Dataset._noop_mode():
|
|
1469
1501
|
return DummyIterator(self, 'dict', output_numpy)
|
|
1470
|
-
return DictIterator(self, num_epochs, output_numpy)
|
|
1502
|
+
return DictIterator(self, num_epochs, output_numpy, do_copy)
|
|
1471
1503
|
|
|
1472
1504
|
def __iter__(self):
|
|
1473
1505
|
"""Create an iterator over the dataset."""
|
|
@@ -1689,6 +1721,39 @@ class Dataset:
|
|
|
1689
1721
|
When num_batch is None, it will default to the number specified by the
|
|
1690
1722
|
sync_wait operation. Default: None.
|
|
1691
1723
|
data (Any): The data passed to the callback, user defined. Default: None.
|
|
1724
|
+
|
|
1725
|
+
Examples:
|
|
1726
|
+
>>> import numpy as np
|
|
1727
|
+
>>>
|
|
1728
|
+
>>>
|
|
1729
|
+
>>> def gen():
|
|
1730
|
+
... for i in range(100):
|
|
1731
|
+
... yield (np.array(i),)
|
|
1732
|
+
>>>
|
|
1733
|
+
>>>
|
|
1734
|
+
>>> class Augment:
|
|
1735
|
+
... def __init__(self, loss):
|
|
1736
|
+
... self.loss = loss
|
|
1737
|
+
...
|
|
1738
|
+
... def preprocess(self, input_):
|
|
1739
|
+
... return input_
|
|
1740
|
+
...
|
|
1741
|
+
... def update(self, data):
|
|
1742
|
+
... self.loss = data["loss"]
|
|
1743
|
+
>>>
|
|
1744
|
+
>>>
|
|
1745
|
+
>>> batch_size = 10
|
|
1746
|
+
>>> dataset = ds.GeneratorDataset(gen, column_names=["input"])
|
|
1747
|
+
>>> aug = Augment(0)
|
|
1748
|
+
>>> dataset = dataset.sync_wait(condition_name='', num_batch=1)
|
|
1749
|
+
>>> dataset = dataset.map(input_columns=["input"], operations=[aug.preprocess])
|
|
1750
|
+
>>> dataset = dataset.batch(batch_size)
|
|
1751
|
+
>>>
|
|
1752
|
+
>>> count = 0
|
|
1753
|
+
>>> for data in dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
|
|
1754
|
+
... count += 1
|
|
1755
|
+
... data = {"loss": count}
|
|
1756
|
+
... dataset.sync_update(condition_name="", data=data)
|
|
1692
1757
|
"""
|
|
1693
1758
|
if (not isinstance(num_batch, int) and num_batch is not None) or \
|
|
1694
1759
|
(isinstance(num_batch, int) and num_batch <= 0):
|
|
@@ -1712,7 +1777,7 @@ class Dataset:
|
|
|
1712
1777
|
Return the size of batch.
|
|
1713
1778
|
|
|
1714
1779
|
Returns:
|
|
1715
|
-
int, the
|
|
1780
|
+
int, the batch size of data.
|
|
1716
1781
|
|
|
1717
1782
|
Examples:
|
|
1718
1783
|
>>> # dataset is an instance object of Dataset
|
|
@@ -1761,7 +1826,18 @@ class Dataset:
|
|
|
1761
1826
|
return {}
|
|
1762
1827
|
|
|
1763
1828
|
def reset(self):
|
|
1764
|
-
"""
|
|
1829
|
+
"""
|
|
1830
|
+
Reset the dataset for next epoch.
|
|
1831
|
+
|
|
1832
|
+
Examples:
|
|
1833
|
+
>>> mind_dataset_dir = ["/path/to/mind_dataset_file"]
|
|
1834
|
+
>>> dataset = ds.MindDataset(dataset_files=mind_dataset_dir)
|
|
1835
|
+
>>> for _ in range(5):
|
|
1836
|
+
... num_iter = 0
|
|
1837
|
+
... for data in dataset.create_tuple_iterator(num_epochs=1, output_numpy=True):
|
|
1838
|
+
... num_iter += 1
|
|
1839
|
+
... dataset.reset()
|
|
1840
|
+
"""
|
|
1765
1841
|
|
|
1766
1842
|
def is_shuffled(self):
|
|
1767
1843
|
"""Returns True if the dataset or its children is shuffled."""
|
|
@@ -1782,6 +1858,15 @@ class Dataset:
|
|
|
1782
1858
|
def parse(self, children=None):
|
|
1783
1859
|
raise NotImplementedError("Dataset has to implement parse method.")
|
|
1784
1860
|
|
|
1861
|
+
def __len__(self):
|
|
1862
|
+
"""
|
|
1863
|
+
Get the length of dataset.
|
|
1864
|
+
|
|
1865
|
+
Returns:
|
|
1866
|
+
int, the length of dataset.
|
|
1867
|
+
"""
|
|
1868
|
+
return self.get_dataset_size()
|
|
1869
|
+
|
|
1785
1870
|
@staticmethod
|
|
1786
1871
|
def _update_data_shard(num_shards, shard_id):
|
|
1787
1872
|
"""
|
|
@@ -1837,6 +1922,10 @@ class TextBaseDataset(Dataset):
|
|
|
1837
1922
|
Build a vocab from a dataset. This would collect all the unique words in a dataset and return a vocab
|
|
1838
1923
|
which contains top_k most frequent words (if top_k is specified).
|
|
1839
1924
|
|
|
1925
|
+
Note:
|
|
1926
|
+
mindspore.dataset.Dataset.build_vocab is deprecated from version 2.0
|
|
1927
|
+
and will be removed in a future version. Use mindspore.dataset.text.Vocab.from_dataset instead.
|
|
1928
|
+
|
|
1840
1929
|
Args:
|
|
1841
1930
|
columns(Union[str, list[str]]): Column names to get words from.
|
|
1842
1931
|
freq_range(tuple[int]): A tuple of integers (min_frequency, max_frequency). Words within the frequency
|
|
@@ -1851,22 +1940,60 @@ class TextBaseDataset(Dataset):
|
|
|
1851
1940
|
|
|
1852
1941
|
Returns:
|
|
1853
1942
|
Vocab, vocab built from the dataset.
|
|
1943
|
+
"""
|
|
1944
|
+
warnings.warn("mindspore.dataset.Dataset.build_vocab is deprecated from version 2.0 "
|
|
1945
|
+
"and will be removed in a future version. "
|
|
1946
|
+
"Use mindspore.dataset.text.Vocab.from_dataset instead.", DeprecationWarning)
|
|
1854
1947
|
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
... # key: word, value: number of occurrences, reason for using letters is so their order is apparent
|
|
1860
|
-
... corpus = {"Z": 4, "Y": 4, "X": 4, "W": 3, "U": 3, "V": 2, "T": 1}
|
|
1861
|
-
... for k, v in corpus.items():
|
|
1862
|
-
... yield (np.array([k] * v, dtype='S'),)
|
|
1863
|
-
>>> column_names = ["column1"]
|
|
1864
|
-
>>> dataset = ds.GeneratorDataset(gen_corpus, column_names)
|
|
1865
|
-
>>> dataset = dataset.build_vocab(columns=["column1"],
|
|
1866
|
-
... freq_range=(1, 10), top_k=5,
|
|
1867
|
-
... special_tokens=["<pad>", "<unk>"],
|
|
1868
|
-
... special_first=True)
|
|
1948
|
+
def build_sentencepiece_vocab(self, columns, vocab_size, character_coverage, model_type, params):
|
|
1949
|
+
"""
|
|
1950
|
+
Function to create a SentencePieceVocab from source dataset.
|
|
1951
|
+
Desired source dataset is a text type dataset.
|
|
1869
1952
|
|
|
1953
|
+
Note:
|
|
1954
|
+
mindspore.dataset.Dataset.build_sentencepiece_vocab is deprecated from version 2.0
|
|
1955
|
+
and will be removed in a future version. Use mindspore.dataset.text.SentencePieceVocab.from_dataset instead.
|
|
1956
|
+
|
|
1957
|
+
Args:
|
|
1958
|
+
columns(list[str]): Column names to get words from.
|
|
1959
|
+
vocab_size(int): Vocabulary size.
|
|
1960
|
+
character_coverage(float): Percentage of characters covered by the model, must be between
|
|
1961
|
+
0.98 and 1.0 Good defaults are: 0.9995 for languages with rich character sets like
|
|
1962
|
+
Japanese or Chinese character sets, and 1.0 for other languages with small character sets
|
|
1963
|
+
like English or Latin.
|
|
1964
|
+
model_type(SentencePieceModel): Model type. Choose from unigram (default), bpe, char, or word.
|
|
1965
|
+
The input sentence must be pretokenized when using word type.
|
|
1966
|
+
params(dict): Any extra optional parameters of sentencepiece library according to your raw data
|
|
1967
|
+
|
|
1968
|
+
Returns:
|
|
1969
|
+
SentencePieceVocab, vocab built from the dataset.
|
|
1970
|
+
"""
|
|
1971
|
+
warnings.warn("mindspore.dataset.Dataset.build_vocab is deprecated from version 2.0 "
|
|
1972
|
+
"and will be removed in a future version. "
|
|
1973
|
+
"Use mindspore.dataset.text.Vocab.from_dataset instead.", DeprecationWarning)
|
|
1974
|
+
|
|
1975
|
+
def _build_vocab(self, columns, freq_range, top_k, special_tokens, special_first):
|
|
1976
|
+
"""
|
|
1977
|
+
Function to create a Vocab from source dataset.
|
|
1978
|
+
Desired source dataset is a text type dataset.
|
|
1979
|
+
|
|
1980
|
+
Build a vocab from a dataset. This would collect all the unique words in a dataset and return a vocab
|
|
1981
|
+
which contains top_k most frequent words (if top_k is specified).
|
|
1982
|
+
|
|
1983
|
+
Args:
|
|
1984
|
+
columns(Union[str, list[str]]): Column names to get words from.
|
|
1985
|
+
freq_range(tuple[int]): A tuple of integers (min_frequency, max_frequency). Words within the frequency
|
|
1986
|
+
range will be stored.
|
|
1987
|
+
Naturally 0 <= min_frequency <= max_frequency <= total_words. min_frequency/max_frequency
|
|
1988
|
+
can be set to default, which corresponds to 0/total_words separately.
|
|
1989
|
+
top_k(int): Number of words to be built into vocab. top_k most frequent words are
|
|
1990
|
+
taken. The top_k is taken after freq_range. If not enough top_k, all words will be taken
|
|
1991
|
+
special_tokens(list[str]): A list of strings, each one is a special token.
|
|
1992
|
+
special_first(bool): Whether special_tokens will be prepended/appended to vocab, If special_tokens
|
|
1993
|
+
is specified and special_first is set to default, special_tokens will be prepended.
|
|
1994
|
+
|
|
1995
|
+
Returns:
|
|
1996
|
+
Vocab, vocab built from the dataset.
|
|
1870
1997
|
"""
|
|
1871
1998
|
vocab = cde.Vocab()
|
|
1872
1999
|
columns = replace_none(columns, [])
|
|
@@ -1899,7 +2026,7 @@ class TextBaseDataset(Dataset):
|
|
|
1899
2026
|
|
|
1900
2027
|
return vocab
|
|
1901
2028
|
|
|
1902
|
-
def
|
|
2029
|
+
def _build_sentencepiece_vocab(self, columns, vocab_size, character_coverage, model_type, params):
|
|
1903
2030
|
"""
|
|
1904
2031
|
Function to create a SentencePieceVocab from source dataset.
|
|
1905
2032
|
Desired source dataset is a text type dataset.
|
|
@@ -1917,13 +2044,6 @@ class TextBaseDataset(Dataset):
|
|
|
1917
2044
|
|
|
1918
2045
|
Returns:
|
|
1919
2046
|
SentencePieceVocab, vocab built from the dataset.
|
|
1920
|
-
|
|
1921
|
-
Examples:
|
|
1922
|
-
>>> from mindspore.dataset.text import SentencePieceModel
|
|
1923
|
-
>>>
|
|
1924
|
-
>>> # You can construct any text dataset as source, take TextFileDataset as example.
|
|
1925
|
-
>>> dataset = ds.TextFileDataset("/path/to/sentence/piece/vocab/file", shuffle=False)
|
|
1926
|
-
>>> dataset = dataset.build_sentencepiece_vocab(["text"], 5000, 0.9995, SentencePieceModel.UNIGRAM, {})
|
|
1927
2047
|
"""
|
|
1928
2048
|
if not isinstance(model_type, SentencePieceModel):
|
|
1929
2049
|
raise TypeError("Argument model_type with value {0} is not of type SentencePieceModel, but got {1}." \
|
|
@@ -2363,6 +2483,10 @@ class BatchDataset(UnionBaseDataset):
|
|
|
2363
2483
|
"""
|
|
2364
2484
|
if self.python_multiprocessing and platform.system().lower() == 'windows':
|
|
2365
2485
|
logger.warning("Python multiprocessing is not supported on Windows platform.")
|
|
2486
|
+
if self.python_multiprocessing and get_debug_mode():
|
|
2487
|
+
logger.warning("Python multiprocessing is not supported in debug mode."
|
|
2488
|
+
" Ignoring Python multiprocessing for batch operation.")
|
|
2489
|
+
self.python_multiprocessing = False
|
|
2366
2490
|
if self.python_multiprocessing and platform.system().lower() != 'windows':
|
|
2367
2491
|
if self.per_batch_map is None:
|
|
2368
2492
|
logger.warning("per_batch_map is None so python_multiprocessing is ignored for batch.")
|
|
@@ -2658,17 +2782,38 @@ class _PythonCallable:
|
|
|
2658
2782
|
self.pool = pool
|
|
2659
2783
|
# Python callable index
|
|
2660
2784
|
self.idx = idx
|
|
2785
|
+
self.check_interval = get_multiprocessing_timeout_interval()
|
|
2661
2786
|
|
|
2662
2787
|
def __call__(self, *args):
|
|
2663
2788
|
result = None
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2789
|
+
start_time = time.time()
|
|
2790
|
+
count = 1
|
|
2791
|
+
get_data_from_worker_process = False
|
|
2792
|
+
while get_data_from_worker_process is False:
|
|
2793
|
+
cost_time = time.time() - start_time
|
|
2794
|
+
if cost_time > (self.check_interval * count):
|
|
2795
|
+
logger.warning("It has been waiting for " + str(cost_time) + "s because the multi "
|
|
2796
|
+
"workers of map operation cost long time to process next data. "
|
|
2797
|
+
"Worker process list are: " + str(self.pool.get_pids()) + ", you can use "
|
|
2798
|
+
"\"py-spy dump -p {PID} -l -s \""
|
|
2799
|
+
"to dump the worker process stack. You can also set the timeout interval by "
|
|
2800
|
+
"ds.config.set_multiprocessing_interval to adjust the output frequency of this "
|
|
2801
|
+
"log.")
|
|
2802
|
+
count += 1
|
|
2803
|
+
if self.pool.is_running() and check_iterator_cleanup() is False:
|
|
2804
|
+
try:
|
|
2805
|
+
result = self.pool.execute(self.idx, *args)
|
|
2806
|
+
except multiprocessing.TimeoutError:
|
|
2807
|
+
continue
|
|
2808
|
+
get_data_from_worker_process = True
|
|
2809
|
+
else:
|
|
2810
|
+
# worker process is stopped
|
|
2811
|
+
logger.info("The worker process of map operation is stopped. "
|
|
2812
|
+
"So return None to main thread and break the main thread.")
|
|
2813
|
+
return None
|
|
2814
|
+
# got value from worker process
|
|
2815
|
+
if not isinstance(result, tuple) and get_data_from_worker_process is True:
|
|
2816
|
+
result = (result,)
|
|
2672
2817
|
return result
|
|
2673
2818
|
|
|
2674
2819
|
def to_json(self):
|
|
@@ -2764,7 +2909,7 @@ def _worker_loop(operations, pipe, seed=get_seed()):
|
|
|
2764
2909
|
pipe.worker_send(output_tensors)
|
|
2765
2910
|
except Exception:
|
|
2766
2911
|
pipe.worker_send(ExceptionHandler(where="in map(or batch) worker and execute Python function"))
|
|
2767
|
-
return
|
|
2912
|
+
# Do not return
|
|
2768
2913
|
|
|
2769
2914
|
|
|
2770
2915
|
def worker_target(operations, seed=get_seed()):
|
|
@@ -2949,6 +3094,12 @@ class _PythonMultiprocessing(cde.PythonMultiprocessingRuntime):
|
|
|
2949
3094
|
# For kill -15, we still exit after 30s
|
|
2950
3095
|
if exit_code == -15:
|
|
2951
3096
|
return 30
|
|
3097
|
+
# In some cases the subprocess has been killed but the exitcode is still None.
|
|
3098
|
+
# So we use os.kill(pid, 0) to check if it is alive.
|
|
3099
|
+
subprocess_alive = _PythonMultiprocessing.is_process_alive(w.pid)
|
|
3100
|
+
if not subprocess_alive:
|
|
3101
|
+
# Like kill -15, we wait 30s before exit
|
|
3102
|
+
return 30
|
|
2952
3103
|
except ValueError:
|
|
2953
3104
|
# process has been closed already
|
|
2954
3105
|
return 0
|
|
@@ -2993,12 +3144,22 @@ class _PythonMultiprocessing(cde.PythonMultiprocessingRuntime):
|
|
|
2993
3144
|
os.kill(os.getpid(), signal.SIGTERM)
|
|
2994
3145
|
|
|
2995
3146
|
def launch(self, op_id=-1):
|
|
3147
|
+
"""
|
|
3148
|
+
Launch Python multiprocessing pool.
|
|
3149
|
+
|
|
3150
|
+
Args:
|
|
3151
|
+
pop_id: ID for operation to have Python multiprocessing pool launched
|
|
3152
|
+
|
|
3153
|
+
Returns:
|
|
3154
|
+
Python multiprocssing pool is launched.
|
|
3155
|
+
"""
|
|
2996
3156
|
self.python_threads_to_workers = {}
|
|
2997
3157
|
self.op_id = op_id
|
|
2998
3158
|
logger.info("Launching new Python Multiprocessing pool for Op:" + str(self.op_id))
|
|
2999
3159
|
if self.is_mp_enabled():
|
|
3000
|
-
|
|
3001
|
-
The existing pool will be terminated first.
|
|
3160
|
+
message = "Launching a new Python multiprocessing pool while a pool already exists!" + \
|
|
3161
|
+
" The existing pool will be terminated first."
|
|
3162
|
+
logger.warning(message)
|
|
3002
3163
|
self.terminate()
|
|
3003
3164
|
self.reset()
|
|
3004
3165
|
self.create_pool()
|
|
@@ -3036,7 +3197,6 @@ class _PythonMultiprocessing(cde.PythonMultiprocessingRuntime):
|
|
|
3036
3197
|
atexit.register(self.terminate)
|
|
3037
3198
|
|
|
3038
3199
|
def terminate(self):
|
|
3039
|
-
logger.info("Terminating Python Multiprocessing for Op:" + str(self.op_id))
|
|
3040
3200
|
self.close_all_workers()
|
|
3041
3201
|
self.abort_watchdog()
|
|
3042
3202
|
|
|
@@ -3113,6 +3273,7 @@ class _PythonMultiprocessing(cde.PythonMultiprocessingRuntime):
|
|
|
3113
3273
|
if platform.system().lower() != 'windows':
|
|
3114
3274
|
self.cleaning_process = multiprocessing.Process(target=self._clean_process,
|
|
3115
3275
|
args=(self.ppid, self.workers),
|
|
3276
|
+
name="OrphanCleaner",
|
|
3116
3277
|
daemon=True)
|
|
3117
3278
|
self.cleaning_process.start()
|
|
3118
3279
|
|
|
@@ -3120,6 +3281,7 @@ class _PythonMultiprocessing(cde.PythonMultiprocessingRuntime):
|
|
|
3120
3281
|
self.eot = threading.Event()
|
|
3121
3282
|
self.watch_dog = threading.Thread(target=self._watch_dog,
|
|
3122
3283
|
args=(self.eot, self.workers + [self.cleaning_process]),
|
|
3284
|
+
name="WatchDog",
|
|
3123
3285
|
daemon=True)
|
|
3124
3286
|
self.watch_dog.start()
|
|
3125
3287
|
|
|
@@ -3212,14 +3374,23 @@ class MapDataset(UnionBaseDataset):
|
|
|
3212
3374
|
if count_new_transforms + count_pyfunc == len(operations):
|
|
3213
3375
|
prev_op = None
|
|
3214
3376
|
for op in operations:
|
|
3377
|
+
# skip user added DebugHook to avoid changing to Py-implementation.
|
|
3378
|
+
if self.__is_debug_hook_op(op):
|
|
3379
|
+
if prev_op:
|
|
3380
|
+
# manually set previous_op_name
|
|
3381
|
+
prev_op_name = self.__parse_op_name(prev_op)
|
|
3382
|
+
op.set_previous_op_name(prev_op_name)
|
|
3383
|
+
continue
|
|
3215
3384
|
if op.implementation is None:
|
|
3216
3385
|
if prev_op and prev_op.implementation == Implementation.PY:
|
|
3217
3386
|
op.implementation = Implementation.PY
|
|
3218
3387
|
else:
|
|
3219
3388
|
op.implementation = Implementation.C
|
|
3220
3389
|
prev_op = op
|
|
3390
|
+
operations = self.__insert_debug_wrapper(operations)
|
|
3221
3391
|
operations = transforms.transforms.Compose.reduce(operations)
|
|
3222
3392
|
elif count_old_transforms + count_pyfunc + count_non_data_vision_transforms == len(operations):
|
|
3393
|
+
operations = self.__insert_debug_wrapper(operations)
|
|
3223
3394
|
operations = transforms.py_transforms.Compose.reduce(operations)
|
|
3224
3395
|
else:
|
|
3225
3396
|
raise RuntimeError("Mixing old legacy c/py_transforms and new unified transforms is not allowed.")
|
|
@@ -3239,6 +3410,49 @@ class MapDataset(UnionBaseDataset):
|
|
|
3239
3410
|
self.process_pool.terminate()
|
|
3240
3411
|
del self.process_pool
|
|
3241
3412
|
|
|
3413
|
+
@staticmethod
|
|
3414
|
+
def __parse_op_name(op):
|
|
3415
|
+
"""
|
|
3416
|
+
Utility method to get operation name.
|
|
3417
|
+
"""
|
|
3418
|
+
op_name = ""
|
|
3419
|
+
if isinstance(op, transforms.py_transforms_util.FuncWrapper):
|
|
3420
|
+
try:
|
|
3421
|
+
op_name = op.transform.__name__
|
|
3422
|
+
except (AttributeError,):
|
|
3423
|
+
op_name = op.transform.__class__.__name__
|
|
3424
|
+
else:
|
|
3425
|
+
op_name = op.__class__.__name__
|
|
3426
|
+
return op_name
|
|
3427
|
+
|
|
3428
|
+
@staticmethod
|
|
3429
|
+
def __construct_debug_hook(previous_op_name=None):
|
|
3430
|
+
"""
|
|
3431
|
+
Wrap debug hook into FuncWrapper.
|
|
3432
|
+
"""
|
|
3433
|
+
inserted_functions = []
|
|
3434
|
+
debug_hook_list = _get_debug_hook_list()
|
|
3435
|
+
if debug_hook_list:
|
|
3436
|
+
for fn in debug_hook_list:
|
|
3437
|
+
# making deep copy to allow each debug hook instance hold unique variables
|
|
3438
|
+
new_fn = copy.deepcopy(fn)
|
|
3439
|
+
new_fn.set_previous_op_name(previous_op_name)
|
|
3440
|
+
inserted_func = transforms.py_transforms_util.FuncWrapper(new_fn)
|
|
3441
|
+
inserted_func.implementation = Implementation.PY
|
|
3442
|
+
inserted_functions.append(inserted_func)
|
|
3443
|
+
return inserted_functions
|
|
3444
|
+
|
|
3445
|
+
@staticmethod
|
|
3446
|
+
def __is_debug_hook_op(op):
|
|
3447
|
+
"""
|
|
3448
|
+
Check if the op is user added DebugHook and skip it to avoid changing transforms implementation.
|
|
3449
|
+
"""
|
|
3450
|
+
if isinstance(op, DebugHook):
|
|
3451
|
+
if not get_debug_mode():
|
|
3452
|
+
raise ValueError("It is not allowed to inject DebugHook object in non-debug mode.")
|
|
3453
|
+
return True
|
|
3454
|
+
return False
|
|
3455
|
+
|
|
3242
3456
|
@staticmethod
|
|
3243
3457
|
def __count_pyfuncs(operations):
|
|
3244
3458
|
"""
|
|
@@ -3304,6 +3518,10 @@ class MapDataset(UnionBaseDataset):
|
|
|
3304
3518
|
if self.python_multiprocessing and platform.system().lower() == 'windows':
|
|
3305
3519
|
logger.warning("Python multiprocessing is not supported on Windows platform.")
|
|
3306
3520
|
return
|
|
3521
|
+
if self.python_multiprocessing and get_debug_mode():
|
|
3522
|
+
logger.warning("Python multiprocessing is not supported in debug mode."
|
|
3523
|
+
" Ignoring Python multiprocessing for map operation.")
|
|
3524
|
+
return
|
|
3307
3525
|
if self.python_multiprocessing:
|
|
3308
3526
|
iter_specific_operations = []
|
|
3309
3527
|
callable_list = []
|
|
@@ -3334,6 +3552,19 @@ class MapDataset(UnionBaseDataset):
|
|
|
3334
3552
|
iter_specific_operations.append(op)
|
|
3335
3553
|
self.operations = iter_specific_operations
|
|
3336
3554
|
|
|
3555
|
+
def __insert_debug_wrapper(self, operations):
|
|
3556
|
+
"""
|
|
3557
|
+
Insert DebuggerWrapper before and after each op if debug mode is on.
|
|
3558
|
+
"""
|
|
3559
|
+
if not get_debug_mode():
|
|
3560
|
+
return operations
|
|
3561
|
+
inserted_operations = self.__construct_debug_hook()
|
|
3562
|
+
for op in operations:
|
|
3563
|
+
inserted_operations.append(op)
|
|
3564
|
+
op_name = self.__parse_op_name(op)
|
|
3565
|
+
inserted_operations.extend(self.__construct_debug_hook(op_name))
|
|
3566
|
+
return inserted_operations
|
|
3567
|
+
|
|
3337
3568
|
def __decompose_callable_operations(self):
|
|
3338
3569
|
"""
|
|
3339
3570
|
Decompose operations and build list of old legacy ops which are callable
|
|
@@ -3606,6 +3837,9 @@ class _ToDevice:
|
|
|
3606
3837
|
"""
|
|
3607
3838
|
|
|
3608
3839
|
def __init__(self, dataset, num_epochs):
|
|
3840
|
+
if get_debug_mode():
|
|
3841
|
+
logger.error("MindData debugger cannot be used in dataset sink mode. Please manually turn off "
|
|
3842
|
+
"sink mode and try debugger again.")
|
|
3609
3843
|
ir_tree, self.api_tree = dataset.create_ir_tree()
|
|
3610
3844
|
|
|
3611
3845
|
self._runtime_context = cde.PythonRuntimeContext()
|
|
@@ -3620,9 +3854,6 @@ class _ToDevice:
|
|
|
3620
3854
|
def send(self):
|
|
3621
3855
|
self._to_device.Send()
|
|
3622
3856
|
|
|
3623
|
-
def _reset(self, step, epoch):
|
|
3624
|
-
self._to_device.Reset(step, epoch)
|
|
3625
|
-
|
|
3626
3857
|
def stop_send(self):
|
|
3627
3858
|
"""
|
|
3628
3859
|
send stop send signal to pipeline, it is used when end of sequence is sent at the epoch end.
|
|
@@ -3661,6 +3892,9 @@ class _ToDevice:
|
|
|
3661
3892
|
offload_model = GetOffloadModel(self._to_device, col_names)
|
|
3662
3893
|
return offload_model
|
|
3663
3894
|
|
|
3895
|
+
def _reset(self, step, epoch):
|
|
3896
|
+
self._to_device.Reset(step, epoch)
|
|
3897
|
+
|
|
3664
3898
|
|
|
3665
3899
|
class TransferDataset(Dataset):
|
|
3666
3900
|
"""
|
|
@@ -3731,11 +3965,6 @@ class TransferDataset(Dataset):
|
|
|
3731
3965
|
if self._to_device is not None:
|
|
3732
3966
|
self._to_device.continue_send()
|
|
3733
3967
|
|
|
3734
|
-
def _reset(self, step, epoch):
|
|
3735
|
-
if self._to_device is not None:
|
|
3736
|
-
logger.info("Reset the dataset pipeline to step: " + str(step) + ", epoch: " + str(epoch))
|
|
3737
|
-
self._to_device._reset(step, epoch) # pylint: disable=W0212
|
|
3738
|
-
|
|
3739
3968
|
def get_data_info(self):
|
|
3740
3969
|
"""
|
|
3741
3970
|
Get type and shape of current batch
|
|
@@ -3757,6 +3986,11 @@ class TransferDataset(Dataset):
|
|
|
3757
3986
|
if self._to_device is not None:
|
|
3758
3987
|
self._to_device.release()
|
|
3759
3988
|
|
|
3989
|
+
def _reset(self, step, epoch):
|
|
3990
|
+
if self._to_device is not None:
|
|
3991
|
+
logger.info("Reset the dataset pipeline to step: " + str(step) + ", epoch: " + str(epoch))
|
|
3992
|
+
self._to_device._reset(step, epoch) # pylint: disable=protected-access
|
|
3993
|
+
|
|
3760
3994
|
|
|
3761
3995
|
class Schema:
|
|
3762
3996
|
"""
|
|
@@ -3797,6 +4031,12 @@ class Schema:
|
|
|
3797
4031
|
|
|
3798
4032
|
Raises:
|
|
3799
4033
|
ValueError: If column type is unknown.
|
|
4034
|
+
|
|
4035
|
+
Examples:
|
|
4036
|
+
>>> from mindspore import dtype as mstype
|
|
4037
|
+
>>>
|
|
4038
|
+
>>> schema = ds.Schema()
|
|
4039
|
+
>>> schema.add_column('col_1d', de_type=mstype.int64, shape=[2])
|
|
3800
4040
|
"""
|
|
3801
4041
|
if isinstance(de_type, typing.Type):
|
|
3802
4042
|
de_type = mstype_to_detype(de_type)
|
|
@@ -3841,6 +4081,12 @@ class Schema:
|
|
|
3841
4081
|
|
|
3842
4082
|
Returns:
|
|
3843
4083
|
str, JSON string of the schema.
|
|
4084
|
+
|
|
4085
|
+
Examples:
|
|
4086
|
+
>>> from mindspore.dataset import Schema
|
|
4087
|
+
>>>
|
|
4088
|
+
>>> schema1 = ds.Schema()
|
|
4089
|
+
>>> schema2 = schema1.to_json()
|
|
3844
4090
|
"""
|
|
3845
4091
|
return self.cpp_schema.to_json()
|
|
3846
4092
|
|
|
@@ -3855,6 +4101,16 @@ class Schema:
|
|
|
3855
4101
|
RuntimeError: if there is unknown item in the object.
|
|
3856
4102
|
RuntimeError: if dataset type is missing in the object.
|
|
3857
4103
|
RuntimeError: if columns are missing in the object.
|
|
4104
|
+
|
|
4105
|
+
Examples:
|
|
4106
|
+
>>> import json
|
|
4107
|
+
>>>
|
|
4108
|
+
>>> from mindspore.dataset import Schema
|
|
4109
|
+
>>>
|
|
4110
|
+
>>> with open("/path/to/schema_file") as file:
|
|
4111
|
+
... json_obj = json.load(file)
|
|
4112
|
+
... schema = ds.Schema()
|
|
4113
|
+
... schema.from_json(json_obj)
|
|
3858
4114
|
"""
|
|
3859
4115
|
self.cpp_schema.from_string(json.dumps(json_obj, indent=2))
|
|
3860
4116
|
|