mindspore 2.0.0a0__cp37-none-any.whl → 2.0.0rc1__cp37-none-any.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/Third_Party_Open_Source_Software_Notice +9064 -0
- mindspore/__init__.py +4 -2
- mindspore/_akg/akg/composite/build_module.py +11 -0
- mindspore/_akg/akg/config/repository_cuda.json +11 -0
- mindspore/_akg/akg/tvm/contrib/nvcc.py +4 -3
- mindspore/_c_dataengine.cpython-37m-aarch64-linux-gnu.so +0 -0
- mindspore/_c_expression.cpython-37m-aarch64-linux-gnu.so +0 -0
- mindspore/_c_mindrecord.cpython-37m-aarch64-linux-gnu.so +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/_mindspore_offline_debug.cpython-37m-aarch64-linux-gnu.so +0 -0
- mindspore/amp.py +52 -57
- mindspore/bin/cache_admin +0 -0
- mindspore/bin/cache_server +0 -0
- 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/config/super_bar_config.json +512 -0
- 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/include/mindapi/base/type_id.h +1 -0
- mindspore/lib/libdnnl.so.2 +0 -0
- mindspore/lib/libicudata.so.69 +0 -0
- mindspore/lib/libicui18n.so.69 +0 -0
- mindspore/lib/libicuuc.so.69 +0 -0
- mindspore/lib/libmindspore.so +0 -0
- mindspore/lib/libmindspore_backend.so +0 -0
- mindspore/lib/libmindspore_common.so +0 -0
- mindspore/lib/libmindspore_core.so +0 -0
- mindspore/lib/libmindspore_glog.so.0 +0 -0
- mindspore/lib/libmindspore_gpr.so.15 +0 -0
- mindspore/lib/libmindspore_grpc++.so.1 +0 -0
- mindspore/lib/libmindspore_grpc.so.15 +0 -0
- mindspore/lib/libmindspore_shared_lib.so +0 -0
- mindspore/lib/libmpi_adapter.so +0 -0
- mindspore/lib/libmpi_collective.so +0 -0
- mindspore/lib/libnnacl.so +0 -0
- mindspore/lib/libopencv_core.so.4.5 +0 -0
- mindspore/lib/libopencv_imgcodecs.so.4.5 +0 -0
- mindspore/lib/libopencv_imgproc.so.4.5 +0 -0
- mindspore/lib/libps_cache.so +0 -0
- mindspore/lib/plugin/ascend/libakg.so +0 -0
- mindspore/lib/plugin/ascend/libascend_collective.so +0 -0
- mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
- mindspore/lib/plugin/ascend/libhccl_plugin.so +0 -0
- mindspore/lib/plugin/ascend/libmindspore_aicpu_kernels.so +0 -0
- mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
- mindspore/lib/plugin/cpu/libakg.so +0 -0
- mindspore/lib/plugin/libmindspore_ascend.so.1 +0 -0
- mindspore/lib/plugin/{libmindspore_ascend.so → libmindspore_ascend.so.2} +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/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/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/scipy/linalg.py +10 -114
- mindspore/scipy/ops.py +2 -2
- mindspore/scipy/ops_wrapper.py +1 -1
- mindspore/scipy/optimize/_bfgs.py +1 -1
- mindspore/scipy/optimize/_lagrange.py +200 -0
- mindspore/scipy/optimize/line_search.py +3 -2
- mindspore/scipy/optimize/minimize.py +41 -2
- mindspore/scipy/sparse/__init__.py +2 -2
- mindspore/scipy/sparse/linalg.py +4 -464
- mindspore/scipy/utils.py +1 -1
- mindspore/scipy/utils_const.py +7 -1
- 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/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 +648 -574
- 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
mindspore/scipy/sparse/linalg.py
CHANGED
|
@@ -16,342 +16,11 @@
|
|
|
16
16
|
from ... import nn
|
|
17
17
|
from ... import numpy as mnp
|
|
18
18
|
from ...ops import functional as F
|
|
19
|
-
from ...
|
|
20
|
-
from ...common import Tensor, CSRTensor, COOTensor, dtype as mstype
|
|
19
|
+
from ...common import Tensor, CSRTensor
|
|
21
20
|
from ...ops.composite.multitype_ops.zeros_like_impl import zeros_like
|
|
22
|
-
from ..
|
|
23
|
-
from ..linalg import cho_factor, cho_solve
|
|
24
|
-
from ..utils import _to_tensor, _safe_normalize, _eps, _norm, _type_check, _value_check, \
|
|
21
|
+
from ..utils import _to_tensor, _norm, _type_check, _value_check, \
|
|
25
22
|
_sparse_check, _matvec
|
|
26
|
-
from ..utils_const import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def gram_schmidt(Q, q):
|
|
30
|
-
"""Do Gram–Schmidt process to normalize vector v"""
|
|
31
|
-
h = mnp.dot(Q.T, q)
|
|
32
|
-
Qh = mnp.dot(Q, h)
|
|
33
|
-
q = q - Qh
|
|
34
|
-
return q, h
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def arnoldi_iteration(k, A, M, V, H):
|
|
38
|
-
"""Performs a single (the k'th) step of the Arnoldi process."""
|
|
39
|
-
v_ = V[..., k]
|
|
40
|
-
v = _matvec(M, _matvec(A, v_))
|
|
41
|
-
v, h = gram_schmidt(V, v)
|
|
42
|
-
_, v_norm_0 = _safe_normalize(v)
|
|
43
|
-
tol = _eps(v) * v_norm_0
|
|
44
|
-
unit_v, v_norm_1 = _safe_normalize(v, tol)
|
|
45
|
-
V[..., k + 1] = unit_v
|
|
46
|
-
h[k + 1] = v_norm_1
|
|
47
|
-
H[k, :] = h
|
|
48
|
-
breakdown = v_norm_1 == 0
|
|
49
|
-
return V, H, breakdown
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def rotate_vectors(H, i, cs, sn):
|
|
53
|
-
"""Rotate vectors."""
|
|
54
|
-
x1 = H[i]
|
|
55
|
-
y1 = H[i + 1]
|
|
56
|
-
x2 = cs * x1 - sn * y1
|
|
57
|
-
y2 = sn * x1 + cs * y1
|
|
58
|
-
H[i] = x2
|
|
59
|
-
H[i + 1] = y2
|
|
60
|
-
return H
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def _high_precision_cho_solve(a, b, data_type=mstype.float64):
|
|
64
|
-
"""As a core computing module of gmres, cholesky solver must explicitly cast to double precision."""
|
|
65
|
-
a = a.astype(mstype.float64)
|
|
66
|
-
b = b.astype(mstype.float64)
|
|
67
|
-
a_a = mnp.dot(a, a.T)
|
|
68
|
-
a_b = mnp.dot(a, b)
|
|
69
|
-
c, lower = cho_factor(a_a, lower=False)
|
|
70
|
-
factor = (c, lower)
|
|
71
|
-
y = cho_solve(factor, a_b)
|
|
72
|
-
return y.astype(data_type)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def _batch_gmres(A, b, x0, tol, restart, maxiter, M, atol):
|
|
76
|
-
"""
|
|
77
|
-
batched gmres: solve the least squares problem from scratch at the end of each GMRES iteration.
|
|
78
|
-
It does not allow for early termination, but has much less overhead on GPUs.
|
|
79
|
-
"""
|
|
80
|
-
# Constant tensor which avoids loop unrolling
|
|
81
|
-
const_int_zero = _to_tensor(0)
|
|
82
|
-
dtype = b.dtype
|
|
83
|
-
_, b_norm = _safe_normalize(b)
|
|
84
|
-
atol = mnp.maximum(tol * b_norm, _to_tensor(atol), dtype=dtype)
|
|
85
|
-
residual = _matvec(M, b - _matvec(A, x0))
|
|
86
|
-
unit_residual, residual_norm = _safe_normalize(residual)
|
|
87
|
-
k = const_int_zero
|
|
88
|
-
x = x0
|
|
89
|
-
while k < maxiter and residual_norm > atol:
|
|
90
|
-
pad_width = ((0, 0),) * unit_residual.ndim + ((0, restart),)
|
|
91
|
-
V = mnp.pad(unit_residual[..., None], pad_width=pad_width)
|
|
92
|
-
H = mnp.eye(restart, restart + 1, dtype=dtype)
|
|
93
|
-
k_iter = const_int_zero
|
|
94
|
-
breakdown = _to_tensor(False)
|
|
95
|
-
while k_iter < restart and mnp.logical_not(breakdown):
|
|
96
|
-
V, H, breakdown = arnoldi_iteration(k_iter, A, M, V, H)
|
|
97
|
-
k_iter += 1
|
|
98
|
-
beta_vec = mnp.zeros((restart + 1,), dtype=dtype)
|
|
99
|
-
beta_vec[0] = residual_norm
|
|
100
|
-
y = _high_precision_cho_solve(H, beta_vec, data_type=dtype)
|
|
101
|
-
dx = mnp.dot(V[..., :-1], y)
|
|
102
|
-
x = x + dx
|
|
103
|
-
residual = _matvec(M, b - _matvec(A, x))
|
|
104
|
-
unit_residual, residual_norm = _safe_normalize(residual)
|
|
105
|
-
k += 1
|
|
106
|
-
return x, F.select(residual_norm > atol, k, const_int_zero)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def _incremental_gmres(A, b, x0, tol, restart, maxiter, M, atol):
|
|
110
|
-
"""
|
|
111
|
-
incremental gmres: builds a QR decomposition for the Krylov subspace incrementally during
|
|
112
|
-
the GMRES process using Givens rotations. This improves numerical stability and gives a free estimate of
|
|
113
|
-
the residual norm that allows for early termination within a single "restart".
|
|
114
|
-
"""
|
|
115
|
-
const_int_zero = _to_tensor(0)
|
|
116
|
-
_, b_norm = _safe_normalize(b)
|
|
117
|
-
atol = mnp.maximum(tol * b_norm, atol)
|
|
118
|
-
|
|
119
|
-
Mb = _matvec(M, b)
|
|
120
|
-
_, Mb_norm = _safe_normalize(Mb)
|
|
121
|
-
ptol = Mb_norm * mnp.minimum(1.0, atol / b_norm)
|
|
122
|
-
|
|
123
|
-
r = _matvec(M, b - _matvec(A, x0))
|
|
124
|
-
r, r_norm = _safe_normalize(r)
|
|
125
|
-
|
|
126
|
-
iters = const_int_zero
|
|
127
|
-
while iters < maxiter and r_norm > atol:
|
|
128
|
-
V = mnp.pad(r[..., None], ((0, 0),) * r.ndim + ((0, restart),))
|
|
129
|
-
dtype = mnp.result_type(b)
|
|
130
|
-
# Use eye() to avoid constructing a singular matrix in case of early
|
|
131
|
-
# Termination
|
|
132
|
-
R = mnp.eye(restart, restart + 1, dtype=dtype)
|
|
133
|
-
givens = mnp.zeros((restart, 2), dtype=dtype)
|
|
134
|
-
beta_vec = mnp.zeros((restart + 1), dtype=dtype)
|
|
135
|
-
beta_vec[0] = r_norm
|
|
136
|
-
|
|
137
|
-
k = const_int_zero
|
|
138
|
-
err = r_norm
|
|
139
|
-
while mnp.logical_and(mnp.less(k, restart), mnp.less(ptol, err)):
|
|
140
|
-
V, R, _ = arnoldi_iteration(k, A, M, V, R)
|
|
141
|
-
# Givens rotation
|
|
142
|
-
row_k = R[k, :]
|
|
143
|
-
i = const_int_zero
|
|
144
|
-
while i < k:
|
|
145
|
-
row_k = rotate_vectors(row_k, i, givens[i, 0], givens[i, 1])
|
|
146
|
-
i += 1
|
|
147
|
-
|
|
148
|
-
if row_k[k + 1] == 0:
|
|
149
|
-
givens[k, 0] = 1
|
|
150
|
-
givens[k, 1] = 0
|
|
151
|
-
else:
|
|
152
|
-
increase = mnp.absolute(row_k[k]) < mnp.absolute(row_k[k + 1])
|
|
153
|
-
t = mnp.where(increase, -row_k[k] / row_k[k + 1], -row_k[k + 1] / row_k[k])
|
|
154
|
-
r = 1 / F.sqrt(1 + mnp.absolute(t) ** 2)
|
|
155
|
-
givens[k, 0] = mnp.where(increase, r * t, r)
|
|
156
|
-
givens[k, 1] = mnp.where(increase, r, r * t)
|
|
157
|
-
|
|
158
|
-
R[k, :] = rotate_vectors(row_k, k, givens[k, 0], givens[k, 1])
|
|
159
|
-
beta_vec = rotate_vectors(beta_vec, k, givens[k, 0], givens[k, 1])
|
|
160
|
-
err = mnp.absolute(beta_vec[k + 1])
|
|
161
|
-
k += 1
|
|
162
|
-
|
|
163
|
-
y = solve_triangular(R[:, :-1], beta_vec[:-1], trans='T', lower=True)
|
|
164
|
-
dx = mnp.dot(V[:, :-1], y)
|
|
165
|
-
|
|
166
|
-
x = x0 + dx
|
|
167
|
-
r = _matvec(M, b - _matvec(A, x))
|
|
168
|
-
r, r_norm = _safe_normalize(r)
|
|
169
|
-
x0 = x
|
|
170
|
-
iters += 1
|
|
171
|
-
return x0, F.select(r_norm > atol, iters, const_int_zero)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
class GMRES(nn.Cell):
|
|
175
|
-
"""
|
|
176
|
-
Given given A and b, GMRES solves the linear system:
|
|
177
|
-
|
|
178
|
-
.. math::
|
|
179
|
-
A x = b
|
|
180
|
-
"""
|
|
181
|
-
|
|
182
|
-
def __init__(self, A, M, solve_method):
|
|
183
|
-
super(GMRES, self).__init__()
|
|
184
|
-
self.A = A
|
|
185
|
-
self.M = M
|
|
186
|
-
self.solve_method = solve_method
|
|
187
|
-
|
|
188
|
-
def construct(self, b, x0, tol, restart, maxiter, atol):
|
|
189
|
-
# Constant tensor which avoids loop unrolling
|
|
190
|
-
x = x0
|
|
191
|
-
info = _to_tensor(0)
|
|
192
|
-
if self.solve_method == 'batched':
|
|
193
|
-
x, info = _batch_gmres(self.A, b, x0, tol, restart, maxiter, self.M, atol)
|
|
194
|
-
elif self.solve_method == "incremental":
|
|
195
|
-
x, info = _incremental_gmres(self.A, b, x0, tol, restart, maxiter, self.M, atol)
|
|
196
|
-
else:
|
|
197
|
-
_raise_value_error("solve_method should be in ('incremental' or 'batched'), but got ", self.solve_method,
|
|
198
|
-
".")
|
|
199
|
-
return x, info
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
class GMRESV2(nn.Cell):
|
|
203
|
-
"""
|
|
204
|
-
This is a new version of GMRES, which contains all parameters in a graph.
|
|
205
|
-
"""
|
|
206
|
-
|
|
207
|
-
def __init__(self, solve_method):
|
|
208
|
-
super(GMRESV2, self).__init__()
|
|
209
|
-
self.solve_method = solve_method
|
|
210
|
-
|
|
211
|
-
def transpose(self, a):
|
|
212
|
-
if isinstance(a, CSRTensor):
|
|
213
|
-
a_coo = a.to_coo()
|
|
214
|
-
row_indices = a_coo.indices[:, 0]
|
|
215
|
-
col_indices = a_coo.indices[:, 1]
|
|
216
|
-
coo_indices = P.Stack(1)([col_indices, row_indices])
|
|
217
|
-
a_t_coo = COOTensor(coo_indices, a_coo.values, a_coo.shape)
|
|
218
|
-
a_t_csr = a_t_coo.to_csr()
|
|
219
|
-
return a_t_csr
|
|
220
|
-
return a.T
|
|
221
|
-
|
|
222
|
-
def construct(self, A, b, x0, tol, restart, maxiter, M, atol):
|
|
223
|
-
x = x0
|
|
224
|
-
info = _to_tensor(0)
|
|
225
|
-
if self.solve_method == 'batched':
|
|
226
|
-
x, info = _batch_gmres(A, b, x0, tol, restart, maxiter, M, atol)
|
|
227
|
-
elif self.solve_method == "incremental":
|
|
228
|
-
x, info = _incremental_gmres(A, b, x0, tol, restart, maxiter, M, atol)
|
|
229
|
-
else:
|
|
230
|
-
_raise_value_error("solve_method should be in ('incremental' or 'batched'), but got ", self.solve_method,
|
|
231
|
-
".")
|
|
232
|
-
return x, info
|
|
233
|
-
|
|
234
|
-
def bprop(self, A, b, x0, tol, restart, maxiter, M, atol, out, dout):
|
|
235
|
-
"""
|
|
236
|
-
Derivatives of `gmres` are implemented via implicit differentiation with
|
|
237
|
-
another `gmres` solve, rather than by differentiating *through* the solver.
|
|
238
|
-
They will be accurate only if both solves converge.
|
|
239
|
-
"""
|
|
240
|
-
n = b.shape[0]
|
|
241
|
-
if not isinstance(M, (Tensor, CSRTensor)):
|
|
242
|
-
M = F.eye(n, n, b.dtype)
|
|
243
|
-
A_T = self.transpose(A)
|
|
244
|
-
grad_b, _ = self.construct(A_T, dout[0], x0, tol, restart, maxiter, M, atol)
|
|
245
|
-
if isinstance(A, CSRTensor):
|
|
246
|
-
grad_a_dense = -1 * F.reshape(grad_b, (n, 1)) * F.reshape(out[0], (1, n))
|
|
247
|
-
values = F.csr_gather(A.indptr, A.indices, grad_a_dense, A.shape)
|
|
248
|
-
grad_a = CSRTensor(A.indptr, A.indices, values, A.shape)
|
|
249
|
-
else:
|
|
250
|
-
grad_a = -1 * F.reshape(grad_b, (n, 1)) * F.reshape(out[0], (1, n))
|
|
251
|
-
return grad_a, grad_b, zeros_like(x0), zeros_like(tol), zeros_like(atol), zeros_like(maxiter), zeros_like(M)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
def gmres(A, b, x0=None, *, tol=1e-5, restart=20, maxiter=None,
|
|
255
|
-
M=None, callback=None, restrt=None, atol=0.0, callback_type=None, solve_method='batched'):
|
|
256
|
-
"""
|
|
257
|
-
Given given A and b, GMRES solves the linear system:
|
|
258
|
-
|
|
259
|
-
.. math::
|
|
260
|
-
A x = b
|
|
261
|
-
|
|
262
|
-
A is specified as a function performing A(vi) -> vf = A @ vi, and in principle
|
|
263
|
-
need not have any particular special properties, such as symmetry. However,
|
|
264
|
-
convergence is often slow for nearly symmetric operators.
|
|
265
|
-
|
|
266
|
-
Note:
|
|
267
|
-
- `gmres` is not supported on Windows platform yet.
|
|
268
|
-
|
|
269
|
-
Args:
|
|
270
|
-
A (Union[Tensor, function]): 2D Tensor or function that calculates the linear
|
|
271
|
-
map (matrix-vector product) :math:`Ax` when called like :math:`A(x)`.
|
|
272
|
-
As function, `A` must return Tensor with the same structure and shape as its input matrix.
|
|
273
|
-
b (Tensor): Right hand side of the linear system representing a single vector.
|
|
274
|
-
Can be stored as a Tensor.
|
|
275
|
-
x0 (Tensor, optional): Starting guess for the solution. Must have the same structure
|
|
276
|
-
as `b`. If this is unspecified, zeroes are used. Default: None.
|
|
277
|
-
tol (float, optional): Tolerances for convergence,
|
|
278
|
-
:math:`norm(residual) <= max(tol*norm(b), atol)`. We do not implement SciPy's
|
|
279
|
-
"legacy" behavior, so MindSpore's tolerance will differ from SciPy unless you
|
|
280
|
-
explicitly pass `atol` to SciPy's `gmres`. Default: 1e-5.
|
|
281
|
-
restart (integer, optional): Size of the Krylov subspace ("number of iterations")
|
|
282
|
-
built between restarts. GMRES works by approximating the true solution x as its
|
|
283
|
-
projection into a Krylov space of this dimension - this parameter
|
|
284
|
-
therefore bounds the maximum accuracy achievable from any guess
|
|
285
|
-
solution. Larger values increase both number of iterations and iteration
|
|
286
|
-
cost, but may be necessary for convergence. The algorithm terminates
|
|
287
|
-
early if convergence is achieved before the full subspace is built. Default: 20.
|
|
288
|
-
maxiter (int): Maximum number of times to rebuild the size-`restart`
|
|
289
|
-
Krylov space starting from the solution found at the last iteration. If GMRES
|
|
290
|
-
halts or is very slow, decreasing this parameter may help. Default: None.
|
|
291
|
-
M (Union[Tensor, function]): Preconditioner for A. The preconditioner should approximate the
|
|
292
|
-
inverse of A. Effective preconditioning dramatically improves the
|
|
293
|
-
rate of convergence, which implies that fewer iterations are needed
|
|
294
|
-
to reach a given error tolerance. Default: None.
|
|
295
|
-
callback (function): User-supplied function to call after each iteration. It is called as callback(args),
|
|
296
|
-
where args are selected by callback_type. Default: None.
|
|
297
|
-
restrt (int, optional): Deprecated, use restart instead. Default: None.
|
|
298
|
-
atol (float, optional): The same as `tol`. Default: 0.0.
|
|
299
|
-
callback_type (str, optional): Callback function argument requested:
|
|
300
|
-
Default: None.
|
|
301
|
-
|
|
302
|
-
- x: current iterate (ndarray), called on every restart
|
|
303
|
-
- pr_norm: relative (preconditioned) residual norm (float), called on every inner iteration
|
|
304
|
-
- legacy (default): same as pr_norm, but also changes the meaning of ‘maxiter’ to count inner
|
|
305
|
-
iterations instead of restart cycles.
|
|
306
|
-
|
|
307
|
-
solve_method (str): There are two kinds of solve methods,'incremental' or 'batched'. Default: "batched".
|
|
308
|
-
|
|
309
|
-
- incremental: builds a QR decomposition for the Krylov subspace incrementally during
|
|
310
|
-
the GMRES process using Givens rotations. This improves numerical stability and gives
|
|
311
|
-
a free estimate of the residual norm that allows for early termination within a single "restart".
|
|
312
|
-
- batched: solve the least squares problem from scratch at the end of each GMRES
|
|
313
|
-
iteration. It does not allow for early termination, but has much less overhead on GPUs.
|
|
314
|
-
|
|
315
|
-
Returns:
|
|
316
|
-
- Tensor, the converged solution. Has the same structure as `b`.
|
|
317
|
-
- Tensor, placeholder for convergence information: 0 : successful exit.
|
|
318
|
-
>0 : convergence to tolerance not achieved, number of iterations. <0 : illegal input or breakdown.
|
|
319
|
-
|
|
320
|
-
Supported Platforms:
|
|
321
|
-
``CPU`` ``GPU``
|
|
322
|
-
|
|
323
|
-
Examples:
|
|
324
|
-
>>> import numpy as onp
|
|
325
|
-
>>> import mindspore.numpy as mnp
|
|
326
|
-
>>> from mindspore.common import Tensor
|
|
327
|
-
>>> from mindspore.scipy.sparse.linalg import gmres
|
|
328
|
-
>>> A = Tensor(mnp.array([[3, 2, 0], [1, -1, 0], [0, 5, 1]], dtype=mnp.float32))
|
|
329
|
-
>>> b = Tensor(mnp.array([2, 4, -1], dtype=mnp.float32))
|
|
330
|
-
>>> x, exitCode = gmres(A, b)
|
|
331
|
-
>>> print(exitCode) # 0 indicates successful convergence
|
|
332
|
-
0
|
|
333
|
-
>>> print(onp.allclose(mnp.dot(A,x).asnumpy(), b.asnumpy()))
|
|
334
|
-
True
|
|
335
|
-
"""
|
|
336
|
-
func_name = "gmres"
|
|
337
|
-
A, M, b, x0 = _sparse_check(func_name, A, M, b, x0)
|
|
338
|
-
size = b.size
|
|
339
|
-
if maxiter is None:
|
|
340
|
-
maxiter = 10 * size # copied from scipy
|
|
341
|
-
_type_check(func_name, tol, float, 'tol')
|
|
342
|
-
_type_check(func_name, restart, int, 'restart')
|
|
343
|
-
_type_check(func_name, maxiter, int, 'maxiter')
|
|
344
|
-
_type_check(func_name, solve_method, str, 'solve_method')
|
|
345
|
-
_value_check(func_name, callback, None, 'callback', op='is', fmt='todo')
|
|
346
|
-
_value_check(func_name, restrt, None, 'restrt', op='is', fmt='todo')
|
|
347
|
-
_value_check(func_name, callback_type, None, 'callback_type', op='is', fmt='todo')
|
|
348
|
-
if restart > size:
|
|
349
|
-
restart = size
|
|
350
|
-
if not is_within_graph(b):
|
|
351
|
-
x, info = GMRES(A, M, solve_method)(b, x0, tol, restart, maxiter, atol)
|
|
352
|
-
else:
|
|
353
|
-
x, info = GMRESV2(solve_method)(A, b, x0, tol, restart, maxiter, M, atol)
|
|
354
|
-
return x, info
|
|
23
|
+
from ..utils_const import is_within_graph
|
|
355
24
|
|
|
356
25
|
|
|
357
26
|
def _cg(A, b, x0, tol, atol, maxiter, M):
|
|
@@ -493,7 +162,7 @@ def cg(A, b, x0=None, *, tol=1e-5, atol=0.0, maxiter=None, M=None, callback=None
|
|
|
493
162
|
TypeError: If `A` and `b` don't have the same data types.
|
|
494
163
|
|
|
495
164
|
Supported Platforms:
|
|
496
|
-
``
|
|
165
|
+
``GPU`` ``CPU``
|
|
497
166
|
|
|
498
167
|
Examples:
|
|
499
168
|
>>> import numpy as onp
|
|
@@ -521,132 +190,3 @@ def cg(A, b, x0=None, *, tol=1e-5, atol=0.0, maxiter=None, M=None, callback=None
|
|
|
521
190
|
else:
|
|
522
191
|
x, info = CGv2()(A, b, x0, tol, atol, maxiter, M)
|
|
523
192
|
return x, info
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
class BiCGStab(nn.Cell):
|
|
527
|
-
"""Figure 2.10 from Barrett R, et al. 'Templates for the sulution of linear systems:
|
|
528
|
-
building blocks for iterative methods', 1994, pg. 24-25
|
|
529
|
-
"""
|
|
530
|
-
|
|
531
|
-
def __init__(self, A, M):
|
|
532
|
-
super(BiCGStab, self).__init__()
|
|
533
|
-
self.A = A
|
|
534
|
-
self.M = M
|
|
535
|
-
|
|
536
|
-
def construct(self, b, x0, tol, atol, maxiter):
|
|
537
|
-
# Constant tensors which avoid loop unrolling
|
|
538
|
-
const_int_zero = _to_tensor(0)
|
|
539
|
-
const_int_neg_one = _to_tensor(-1)
|
|
540
|
-
|
|
541
|
-
const_float_one = _to_tensor(1., dtype=b.dtype)
|
|
542
|
-
atol_ = mnp.maximum(atol, tol * _norm(b))
|
|
543
|
-
|
|
544
|
-
r = r_tilde = v = p = b - _matvec(self.A, x0)
|
|
545
|
-
rho = alpha = omega = const_float_one
|
|
546
|
-
k = const_int_zero
|
|
547
|
-
x = x0
|
|
548
|
-
while k < maxiter:
|
|
549
|
-
rho_ = mnp.dot(r_tilde, r)
|
|
550
|
-
if rho_ == 0. or omega == 0.:
|
|
551
|
-
k = const_int_neg_one
|
|
552
|
-
break
|
|
553
|
-
|
|
554
|
-
beta = rho_ / rho * (alpha / omega)
|
|
555
|
-
p = r + beta * (p - omega * v)
|
|
556
|
-
p_hat = _matvec(self.M, p)
|
|
557
|
-
v = _matvec(self.A, p_hat)
|
|
558
|
-
alpha = rho_ / mnp.dot(r_tilde, v)
|
|
559
|
-
s = r - alpha * v
|
|
560
|
-
x = x + alpha * p_hat
|
|
561
|
-
if _norm(s) <= atol_:
|
|
562
|
-
break
|
|
563
|
-
|
|
564
|
-
s_hat = _matvec(self.M, s)
|
|
565
|
-
t = _matvec(self.A, s_hat)
|
|
566
|
-
omega = mnp.dot(t, s) / mnp.dot(t, t)
|
|
567
|
-
x = x + omega * s_hat
|
|
568
|
-
r = s - omega * t
|
|
569
|
-
if _norm(r) <= atol_:
|
|
570
|
-
break
|
|
571
|
-
|
|
572
|
-
rho = rho_
|
|
573
|
-
k += 1
|
|
574
|
-
|
|
575
|
-
return x, F.select(k == const_int_neg_one or k >= maxiter, k, const_int_zero)
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
def bicgstab(A, b, x0=None, *, tol=1e-5, atol=0.0, maxiter=None, M=None):
|
|
579
|
-
"""Use Bi-Conjugate Gradient Stable iteration to solve :math:`Ax = b`.
|
|
580
|
-
|
|
581
|
-
The numerics of MindSpore's `bicgstab` should exact match SciPy's
|
|
582
|
-
`bicgstab` (up to numerical precision).
|
|
583
|
-
|
|
584
|
-
As with `cg`, derivatives of `bicgstab` are implemented via implicit
|
|
585
|
-
differentiation with another `bicgstab` solve, rather than by
|
|
586
|
-
differentiating *through* the solver. They will be accurate only if
|
|
587
|
-
both solves converge.
|
|
588
|
-
|
|
589
|
-
Note:
|
|
590
|
-
- `bicgstab` is not supported on Windows platform yet.
|
|
591
|
-
|
|
592
|
-
Args:
|
|
593
|
-
A (Union[Tensor, function]): 2D Tensor or function that calculates the linear
|
|
594
|
-
map (matrix-vector product) :math:`Ax` when called like :math:`A(x)`.
|
|
595
|
-
As function, `A` must return Tensor with the same structure and shape as its input matrix.
|
|
596
|
-
b (Tensor): Right hand side of the linear system representing a single vector. Can be
|
|
597
|
-
stored as a Tensor.
|
|
598
|
-
x0 (Tensor): Starting guess for the solution. Must have the same structure as `b`. Default: None.
|
|
599
|
-
tol (float, optional): Tolerances for convergence, :math:`norm(residual) <= max(tol*norm(b), atol)`.
|
|
600
|
-
We do not implement SciPy's "legacy" behavior, so MindSpore's tolerance will
|
|
601
|
-
differ from SciPy unless you explicitly pass `atol` to SciPy's `bicgstab`. Default: 1e-5.
|
|
602
|
-
atol (float, optional): The same as `tol`. Default: 0.0.
|
|
603
|
-
maxiter (int): Maximum number of iterations. Iteration will stop after maxiter
|
|
604
|
-
steps even if the specified tolerance has not been achieved. Default: None.
|
|
605
|
-
M (Union[Tensor, function]): Preconditioner for A. The preconditioner should approximate the
|
|
606
|
-
inverse of A. Effective preconditioning dramatically improves the
|
|
607
|
-
rate of convergence, which implies that fewer iterations are needed
|
|
608
|
-
to reach a given error tolerance. Default: None.
|
|
609
|
-
|
|
610
|
-
Returns:
|
|
611
|
-
- Tensor, the converged solution. Has the same structure as `b`.
|
|
612
|
-
- Tensor, placeholder for convergence information: 0 : successful exit.
|
|
613
|
-
>0 : convergence to tolerance not achieved, number of iterations. <0 : illegal input or breakdown.
|
|
614
|
-
|
|
615
|
-
Raises:
|
|
616
|
-
ValueError: If `x0` and `b` don't have the same structure.
|
|
617
|
-
TypeError: If `A`, `x0` and `b` don't have the same float types(`mstype.float32` or `mstype.float64`).
|
|
618
|
-
|
|
619
|
-
Supported Platforms:
|
|
620
|
-
``CPU`` ``GPU``
|
|
621
|
-
|
|
622
|
-
Examples:
|
|
623
|
-
>>> import numpy as onp
|
|
624
|
-
>>> from mindspore.common import Tensor
|
|
625
|
-
>>> from mindspore.scipy.sparse.linalg import bicgstab
|
|
626
|
-
>>> A = Tensor(onp.array([[1, 2], [2, 1]], dtype='float32'))
|
|
627
|
-
>>> b = Tensor(onp.array([1, -1], dtype='float32'))
|
|
628
|
-
>>> result, info = bicgstab(A, b)
|
|
629
|
-
>>> print(result)
|
|
630
|
-
[-1. 1.]
|
|
631
|
-
>>> print(info)
|
|
632
|
-
0
|
|
633
|
-
"""
|
|
634
|
-
if x0 is None:
|
|
635
|
-
x0 = mnp.zeros_like(b)
|
|
636
|
-
|
|
637
|
-
if maxiter is None:
|
|
638
|
-
maxiter = 10 * b.shape[0]
|
|
639
|
-
|
|
640
|
-
if M is None:
|
|
641
|
-
M = lambda x: x
|
|
642
|
-
|
|
643
|
-
if x0.shape != b.shape:
|
|
644
|
-
_raise_value_error(
|
|
645
|
-
'Input x0 and b must have matching shapes: ', x0.shape, ' vs ', b.shape)
|
|
646
|
-
|
|
647
|
-
if (F.dtype(b) not in (mstype.float32, mstype.float64)) or (F.dtype(b) != F.dtype(x0)) or (
|
|
648
|
-
F.dtype(b) != F.dtype(A)):
|
|
649
|
-
_raise_type_error('Input A, x0 and b must have same float types')
|
|
650
|
-
|
|
651
|
-
x, info = BiCGStab(A, M)(b, x0, tol, atol, maxiter)
|
|
652
|
-
return x, info
|
mindspore/scipy/utils.py
CHANGED
|
@@ -157,7 +157,7 @@ def _solve_check(func_name, arg1, arg2, arg1_name='a', arg2_name='b', sparse=Fal
|
|
|
157
157
|
|
|
158
158
|
|
|
159
159
|
def _sparse_check(func_name, a, m, b, x0):
|
|
160
|
-
"""Used for cg
|
|
160
|
+
"""Used for cg method."""
|
|
161
161
|
|
|
162
162
|
def _check_right(arg, arg_name):
|
|
163
163
|
if arg is None:
|
mindspore/scipy/utils_const.py
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
from __future__ import absolute_import
|
|
17
17
|
from types import FunctionType
|
|
18
18
|
from collections.abc import Iterable
|
|
19
|
+
from mindspore.ops import functional as F
|
|
19
20
|
from .. import context
|
|
20
21
|
from ..ops.primitive import constexpr
|
|
21
22
|
from ..common import Tensor, CSRTensor
|
|
@@ -29,13 +30,18 @@ def _callable_const(x):
|
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
@constexpr
|
|
33
|
+
def is_pynative():
|
|
34
|
+
"""Returns true if the current mode is PYNATIVE mode."""
|
|
35
|
+
return context.get_context("mode") == context.PYNATIVE_MODE
|
|
36
|
+
|
|
37
|
+
|
|
32
38
|
def is_within_graph(x):
|
|
33
39
|
"""
|
|
34
40
|
Returns true if x is None. It's aim to check whether the call is within MindSpore graph.
|
|
35
41
|
Because in graph mode, x should be None in constexpr when x is a variable of MindSpore.
|
|
36
42
|
Note that always return true if the call is in pynative mode.
|
|
37
43
|
"""
|
|
38
|
-
return
|
|
44
|
+
return is_pynative() or not F.isconstant(x) or x is None
|
|
39
45
|
|
|
40
46
|
|
|
41
47
|
@constexpr
|
mindspore/train/__init__.py
CHANGED
|
@@ -35,7 +35,7 @@ from mindspore.train.train_thor import ConvertNetUtils, ConvertModelUtils
|
|
|
35
35
|
from mindspore.train.metrics import *
|
|
36
36
|
from mindspore.train.data_sink import data_sink
|
|
37
37
|
|
|
38
|
-
__all__ = ["Model", "DatasetHelper", "
|
|
38
|
+
__all__ = ["Model", "DatasetHelper", "connect_network_with_dataset", "build_train_network", "LossScaleManager",
|
|
39
39
|
"FixedLossScaleManager", "DynamicLossScaleManager", "save_checkpoint", "load_checkpoint",
|
|
40
40
|
"load_param_into_net", "export", "load", "parse_print", "build_searched_strategy", "merge_sliced_parameter",
|
|
41
41
|
"load_distributed_checkpoint", "async_ckpt_thread_status", "restore_group_info_list", "convert_model",
|
mindspore/train/_utils.py
CHANGED
|
@@ -20,16 +20,18 @@ from collections.abc import Iterable
|
|
|
20
20
|
import numpy as np
|
|
21
21
|
|
|
22
22
|
from mindspore.common.tensor import Tensor
|
|
23
|
+
from mindspore._c_expression import Tensor as Tensor_
|
|
23
24
|
from mindspore.common.dtype import dtype_to_nptype, pytype_to_dtype
|
|
24
25
|
from mindspore.common import dtype as mstype
|
|
25
26
|
from mindspore import log as logger
|
|
26
|
-
from mindspore
|
|
27
|
+
from mindspore import _checkparam as Validator
|
|
27
28
|
from mindspore.common.api import _cell_graph_executor
|
|
28
29
|
from mindspore.train.mind_ir_pb2 import ModelProto as mindir_model
|
|
29
30
|
from mindspore.train.checkpoint_pb2 import Checkpoint
|
|
30
31
|
from mindspore.train.node_strategy_pb2 import ParallelStrategyMap as ckpt_strategy
|
|
31
32
|
from mindspore.train.lineage_pb2 import DatasetGraph, TrainLineage, EvaluationLineage, UserDefinedInfo
|
|
32
33
|
from mindspore.parallel._parallel_serialization import _make_dir
|
|
34
|
+
from mindspore.ops.operations import debug_ops
|
|
33
35
|
|
|
34
36
|
|
|
35
37
|
def _convert_type(types):
|
|
@@ -135,27 +137,48 @@ def _construct_input_tensors(dataset_types, dataset_shapes, device_number=1):
|
|
|
135
137
|
return tensor_list_run, tensor_list_compile
|
|
136
138
|
|
|
137
139
|
|
|
138
|
-
def _check_to_numpy(plugin, tensor):
|
|
140
|
+
def _check_to_numpy(plugin, tensor, prim=None):
|
|
139
141
|
"""Check the tensor and return a numpy.ndarray."""
|
|
140
142
|
np_value = tensor.asnumpy()
|
|
141
143
|
np_value = np_value.copy()
|
|
144
|
+
summary_name = plugin.capitalize() + "Summary" if prim else "SummaryRecord"
|
|
142
145
|
if plugin == 'scalar':
|
|
143
146
|
if np_value.size == 1:
|
|
144
147
|
return np_value
|
|
145
|
-
raise ValueError(
|
|
148
|
+
raise ValueError(
|
|
149
|
+
f'For "{summary_name}", the v rank must be less than or equal to 1, but got {len(np_value)}.')
|
|
146
150
|
if plugin == 'image':
|
|
147
151
|
if np_value.ndim == 4:
|
|
148
152
|
return np_value
|
|
149
|
-
raise ValueError('The tensor seems not to hold a valid image.')
|
|
153
|
+
raise ValueError(f'For "{summary_name}", The tensor seems not to hold a valid image.')
|
|
150
154
|
if plugin in ('tensor', 'histogram'):
|
|
151
155
|
if np_value.ndim > 0:
|
|
152
156
|
return np_value
|
|
153
|
-
raise ValueError('The
|
|
157
|
+
raise ValueError(f'For "{summary_name}", The value should not be empty.')
|
|
154
158
|
return np_value
|
|
155
159
|
|
|
156
160
|
|
|
161
|
+
def check_summary_param(summary_name, tag, tensor):
|
|
162
|
+
"""Checks the tag is valid for summary."""
|
|
163
|
+
plugin = summary_name.split('Summary')[0].lower()
|
|
164
|
+
try:
|
|
165
|
+
if not isinstance(tag, str) or not tag:
|
|
166
|
+
raise TypeError(f'For "{summary_name}", the name must be valid string, but got "{tag}".')
|
|
167
|
+
if not isinstance(tensor, (Tensor, Tensor_)):
|
|
168
|
+
raise TypeError(f'For "{summary_name}", the parameter "value" expect to be Tensor, '
|
|
169
|
+
f'but got {type(tensor).__name__}')
|
|
170
|
+
_check_to_numpy(plugin, tensor, prim=True)
|
|
171
|
+
except TypeError as err:
|
|
172
|
+
raise TypeError(err)
|
|
173
|
+
except ValueError as err:
|
|
174
|
+
raise ValueError(err)
|
|
175
|
+
finally:
|
|
176
|
+
debug_ops.SUMMARY_TENSOR_CACHE = []
|
|
177
|
+
|
|
178
|
+
|
|
157
179
|
def _check_lineage_value(plugin, value):
|
|
158
180
|
"""Check the lineage value."""
|
|
181
|
+
|
|
159
182
|
def raises(plugin, prototype):
|
|
160
183
|
raise TypeError(f'Plugin {repr(plugin)} expects a {prototype.__name__} value.')
|
|
161
184
|
|