mindspore 2.1.0__cp39-cp39-win_amd64.whl → 2.2.11__cp39-cp39-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 -1
- mindspore/_c_dataengine.cp39-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp39-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp39-win_amd64.pyd +0 -0
- mindspore/_check_jit_forbidden_api.py +3 -1
- mindspore/_checkparam.py +23 -29
- mindspore/_extends/graph_kernel/__init__.py +0 -1
- mindspore/_extends/graph_kernel/model/graph_split.py +84 -76
- mindspore/_extends/graph_kernel/model/model_builder.py +9 -50
- mindspore/_extends/graph_kernel/splitter.py +4 -11
- mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +122 -15
- mindspore/_extends/parallel_compile/akg_compiler/build_tbe_kernel.py +84 -67
- mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +4 -2
- mindspore/_extends/parallel_compile/akg_compiler/util.py +10 -7
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +2 -2
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +6 -5
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_job.py +1 -1
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_job_manager.py +1 -1
- mindspore/_extends/parse/__init__.py +13 -15
- mindspore/_extends/parse/namespace.py +7 -33
- mindspore/_extends/parse/parser.py +67 -72
- mindspore/_extends/parse/resources.py +1 -1
- mindspore/_extends/parse/standard_method.py +86 -106
- mindspore/_extends/parse/trope.py +1 -1
- mindspore/_extends/remote/kernel_build_server.py +25 -7
- mindspore/_extends/remote/kernel_build_server_akg_v2.py +55 -0
- mindspore/_install_custom.py +43 -0
- mindspore/amp.py +47 -11
- mindspore/boost/boost.py +1 -8
- mindspore/boost/boost_cell_wrapper.py +3 -2
- mindspore/boost/grad_accumulation.py +1 -1
- mindspore/boost/group_loss_scale_manager.py +8 -7
- mindspore/common/__init__.py +5 -3
- mindspore/common/_jit_fallback_utils.py +6 -0
- mindspore/common/_register_for_adapter.py +2 -0
- mindspore/common/_register_for_tensor.py +2 -2
- mindspore/common/_stub_tensor.py +13 -0
- mindspore/common/_utils.py +29 -0
- mindspore/common/api.py +174 -259
- mindspore/common/auto_dynamic_shape.py +494 -0
- mindspore/common/dtype.py +18 -11
- mindspore/common/dump.py +6 -4
- mindspore/common/initializer.py +14 -14
- mindspore/common/jit_config.py +33 -15
- mindspore/common/lazy_inline.py +126 -7
- mindspore/common/mindir_util.py +101 -0
- mindspore/common/parameter.py +51 -41
- mindspore/common/seed.py +4 -4
- mindspore/common/sparse_tensor.py +13 -14
- mindspore/common/tensor.py +243 -165
- mindspore/communication/__init__.py +7 -4
- mindspore/communication/_comm_helper.py +83 -4
- mindspore/communication/management.py +152 -84
- mindspore/config/op_info.config +14 -3
- mindspore/context.py +152 -61
- mindspore/dataset/__init__.py +5 -5
- mindspore/dataset/audio/__init__.py +2 -2
- mindspore/dataset/audio/transforms.py +52 -52
- mindspore/dataset/callback/ds_callback.py +16 -2
- mindspore/dataset/core/config.py +68 -51
- mindspore/dataset/engine/cache_client.py +33 -7
- mindspore/dataset/engine/datasets.py +250 -112
- mindspore/dataset/engine/datasets_audio.py +43 -211
- mindspore/dataset/engine/datasets_standard_format.py +16 -35
- mindspore/dataset/engine/datasets_text.py +43 -67
- mindspore/dataset/engine/datasets_user_defined.py +86 -100
- mindspore/dataset/engine/datasets_vision.py +219 -1029
- mindspore/dataset/engine/iterators.py +11 -4
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +4 -0
- mindspore/dataset/engine/obs/util.py +3 -0
- mindspore/dataset/engine/samplers.py +1 -1
- mindspore/dataset/engine/validators.py +19 -5
- mindspore/dataset/text/__init__.py +3 -3
- mindspore/dataset/text/transforms.py +101 -127
- mindspore/dataset/text/utils.py +205 -138
- mindspore/dataset/transforms/__init__.py +1 -1
- mindspore/dataset/transforms/py_transforms_util.py +40 -12
- mindspore/dataset/transforms/transforms.py +95 -40
- mindspore/dataset/utils/browse_dataset.py +8 -2
- mindspore/dataset/utils/line_reader.py +17 -19
- mindspore/dataset/vision/__init__.py +3 -3
- mindspore/dataset/vision/c_transforms.py +6 -3
- mindspore/dataset/vision/transforms.py +409 -287
- mindspore/dataset/vision/utils.py +13 -14
- mindspore/dataset/vision/validators.py +11 -1
- mindspore/dnnl.dll +0 -0
- mindspore/experimental/map_parameter.py +14 -0
- mindspore/{nn/optim_ex → experimental/optim}/__init__.py +30 -29
- mindspore/{nn/optim_ex → experimental/optim}/adam.py +60 -67
- mindspore/{nn/optim_ex → experimental/optim}/adamw.py +181 -203
- mindspore/experimental/optim/lr_scheduler.py +1427 -0
- mindspore/{nn/optim_ex → experimental/optim}/optimizer.py +252 -259
- mindspore/{nn/optim_ex → experimental/optim}/sgd.py +147 -152
- mindspore/gen_ops.py +273 -0
- mindspore/include/OWNERS +0 -1
- mindspore/include/api/data_type.h +2 -1
- mindspore/include/api/graph.h +0 -15
- mindspore/include/api/kernel.h +2 -0
- mindspore/include/api/kernel_api.h +37 -12
- mindspore/include/api/model.h +17 -14
- mindspore/include/api/status.h +8 -3
- mindspore/include/api/types.h +37 -4
- mindspore/include/c_api/ms/abstract.h +67 -0
- mindspore/include/c_api/ms/attribute.h +197 -0
- mindspore/include/c_api/ms/base/handle_types.h +43 -0
- mindspore/include/c_api/ms/base/macros.h +32 -0
- mindspore/include/c_api/ms/base/status.h +33 -0
- mindspore/include/c_api/ms/base/types.h +282 -0
- mindspore/include/c_api/ms/context.h +102 -0
- mindspore/include/c_api/ms/graph.h +160 -0
- mindspore/include/c_api/ms/node.h +606 -0
- mindspore/include/c_api/ms/tensor.h +161 -0
- mindspore/include/c_api/ms/value.h +84 -0
- mindspore/include/dataset/constants.h +6 -5
- mindspore/include/dataset/execute.h +23 -13
- mindspore/include/dataset/text.h +26 -26
- mindspore/include/dataset/transforms.h +13 -13
- mindspore/include/dataset/vision.h +60 -60
- mindspore/include/dataset/vision_ascend.h +5 -6
- mindspore/include/dataset/vision_lite.h +17 -17
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/imagenet_to_mr.py +1 -1
- mindspore/mindrecord/tools/mnist_to_mr.py +2 -2
- 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 -2
- mindspore/nn/cell.py +313 -74
- mindspore/nn/dynamic_lr.py +21 -21
- mindspore/nn/layer/activation.py +22 -30
- mindspore/nn/layer/basic.py +15 -13
- mindspore/nn/layer/channel_shuffle.py +1 -1
- mindspore/nn/layer/container.py +271 -9
- mindspore/nn/layer/conv.py +323 -204
- mindspore/nn/layer/dense.py +8 -5
- mindspore/nn/layer/embedding.py +33 -27
- mindspore/nn/layer/flash_attention.py +61 -95
- mindspore/nn/layer/image.py +8 -6
- mindspore/nn/layer/math.py +16 -25
- mindspore/nn/layer/normalization.py +107 -66
- mindspore/nn/layer/padding.py +1 -1
- mindspore/nn/layer/pooling.py +131 -109
- mindspore/nn/layer/rnn_cells.py +27 -22
- mindspore/nn/layer/rnns.py +13 -16
- mindspore/nn/layer/thor_layer.py +1 -1
- mindspore/nn/layer/transformer.py +221 -154
- mindspore/nn/learning_rate_schedule.py +9 -1
- mindspore/nn/loss/loss.py +235 -174
- mindspore/nn/optim/ada_grad.py +2 -1
- mindspore/nn/optim/adadelta.py +1 -0
- mindspore/nn/optim/adafactor.py +2 -1
- mindspore/nn/optim/adam.py +7 -4
- mindspore/nn/optim/adamax.py +3 -2
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/asgd.py +2 -3
- mindspore/nn/optim/ftrl.py +6 -5
- mindspore/nn/optim/lamb.py +7 -4
- mindspore/nn/optim/lars.py +1 -1
- mindspore/nn/optim/lazyadam.py +5 -3
- mindspore/nn/optim/momentum.py +2 -1
- mindspore/nn/optim/optimizer.py +53 -4
- mindspore/nn/optim/proximal_ada_grad.py +3 -4
- mindspore/nn/optim/rmsprop.py +4 -3
- mindspore/nn/optim/rprop.py +23 -12
- mindspore/nn/optim/sgd.py +26 -11
- mindspore/nn/optim/thor.py +9 -7
- mindspore/nn/probability/bijector/bijector.py +5 -5
- mindspore/nn/probability/bijector/power_transform.py +27 -27
- mindspore/nn/probability/bijector/softplus.py +3 -3
- mindspore/nn/probability/distribution/_utils/custom_ops.py +3 -3
- mindspore/nn/probability/distribution/bernoulli.py +5 -5
- mindspore/nn/probability/distribution/beta.py +3 -3
- mindspore/nn/probability/distribution/categorical.py +7 -7
- mindspore/nn/probability/distribution/cauchy.py +0 -1
- mindspore/nn/probability/distribution/distribution.py +3 -3
- mindspore/nn/probability/distribution/gamma.py +3 -3
- mindspore/nn/probability/distribution/geometric.py +4 -4
- mindspore/nn/probability/distribution/gumbel.py +4 -4
- mindspore/nn/probability/distribution/log_normal.py +2 -2
- mindspore/nn/probability/distribution/logistic.py +2 -2
- mindspore/nn/probability/distribution/poisson.py +4 -4
- mindspore/nn/probability/distribution/transformed_distribution.py +3 -3
- mindspore/nn/probability/distribution/uniform.py +6 -6
- mindspore/nn/wrap/__init__.py +4 -2
- mindspore/nn/wrap/cell_wrapper.py +87 -34
- mindspore/nn/wrap/grad_reducer.py +8 -5
- mindspore/nn/wrap/loss_scale.py +105 -42
- mindspore/numpy/array_creations.py +1 -2
- mindspore/numpy/array_ops.py +3 -2
- mindspore/numpy/utils_const.py +5 -5
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/__init__.py +0 -5
- mindspore/ops/_grad_experimental/grad_array_ops.py +2 -3
- mindspore/ops/_grad_experimental/grad_comm_ops.py +15 -2
- mindspore/ops/_grad_experimental/grad_debug_ops.py +0 -37
- mindspore/ops/_grad_experimental/grad_implementations.py +11 -1
- mindspore/ops/_grad_experimental/grad_inner_ops.py +2 -216
- mindspore/ops/_grad_experimental/grad_math_ops.py +19 -199
- mindspore/ops/_grad_experimental/grad_sparse.py +15 -0
- mindspore/ops/_grad_experimental/grad_sparse_ops.py +3 -3
- mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py +1 -1
- mindspore/ops/_op_impl/aicpu/__init__.py +14 -2
- mindspore/ops/_op_impl/aicpu/add.py +3 -3
- mindspore/ops/_op_impl/aicpu/bias_add_grad.py +0 -1
- mindspore/ops/_op_impl/aicpu/count_nonzero.py +43 -0
- mindspore/ops/_op_impl/{_custom_op/flash_attention/constants.py → aicpu/eps.py} +18 -27
- mindspore/ops/_op_impl/aicpu/gamma.py +2 -2
- mindspore/ops/_op_impl/aicpu/linear_sum_assignment.py +21 -2
- mindspore/ops/_op_impl/aicpu/log_uniform_candidate_sampler.py +6 -3
- mindspore/ops/_op_impl/aicpu/lu_unpack_grad.py +0 -1
- mindspore/ops/_op_impl/aicpu/multinomial.py +3 -3
- mindspore/ops/_op_impl/aicpu/parameterized_truncated_normal.py +15 -7
- mindspore/ops/_op_impl/aicpu/random_categorical.py +39 -19
- mindspore/ops/_op_impl/aicpu/random_choice_with_mask.py +5 -2
- mindspore/ops/_op_impl/aicpu/random_poisson.py +103 -52
- mindspore/ops/_op_impl/aicpu/random_shuffle.py +17 -15
- mindspore/ops/_op_impl/aicpu/{sparseaddmm.py → sparse_addmm.py} +2 -2
- mindspore/ops/_op_impl/aicpu/{sparsesparsemaximum.py → sparse_sparse_maximum.py} +4 -4
- mindspore/ops/_op_impl/aicpu/standard_laplace.py +5 -5
- mindspore/ops/_op_impl/aicpu/standard_normal.py +5 -5
- mindspore/ops/_op_impl/aicpu/truncated_normal.py +9 -7
- mindspore/ops/_op_impl/aicpu/uniform.py +5 -3
- mindspore/ops/_op_impl/aicpu/uniform_candidate_sampler.py +8 -4
- mindspore/ops/_op_impl/aicpu/uniform_int.py +5 -5
- mindspore/ops/_op_impl/aicpu/uniform_real.py +4 -4
- mindspore/ops/_op_impl/tbe/__init__.py +4 -4
- mindspore/ops/_op_impl/tbe/inplace_index_add.py +7 -3
- mindspore/ops/_op_impl/tbe/trans_data_ds.py +2 -0
- mindspore/ops/_primitive_cache.py +1 -1
- mindspore/ops/_tracefunc.py +45 -13
- mindspore/ops/_utils/utils.py +6 -1
- mindspore/ops/_vmap/vmap_array_ops.py +3 -3
- mindspore/ops/_vmap/vmap_base.py +3 -3
- mindspore/ops/_vmap/vmap_convolution_ops.py +1 -1
- mindspore/ops/_vmap/vmap_grad_math_ops.py +6 -4
- mindspore/ops/_vmap/vmap_math_ops.py +5 -2
- mindspore/ops/_vmap/vmap_nn_ops.py +61 -7
- mindspore/ops/arg_dtype_cast.py +54 -0
- mindspore/ops/composite/base.py +37 -10
- mindspore/ops/composite/math_ops.py +5 -4
- mindspore/ops/composite/multitype_ops/_compile_utils.py +275 -73
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +16 -9
- mindspore/ops/composite/multitype_ops/add_impl.py +43 -4
- mindspore/ops/composite/multitype_ops/getitem_impl.py +42 -4
- mindspore/ops/composite/multitype_ops/ones_like_impl.py +6 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +9 -0
- mindspore/ops/deprecated.py +304 -0
- mindspore/ops/function/__init__.py +4 -1
- mindspore/ops/function/array_func.py +174 -193
- mindspore/ops/function/clip_func.py +81 -13
- mindspore/ops/function/debug_func.py +1 -1
- mindspore/ops/function/grad/grad_func.py +18 -9
- mindspore/ops/function/image_func.py +10 -4
- mindspore/ops/function/linalg_func.py +5 -5
- mindspore/ops/function/math_func.py +575 -386
- mindspore/ops/function/nn_func.py +568 -260
- mindspore/ops/function/random_func.py +88 -57
- mindspore/ops/function/sparse_func.py +1 -1
- mindspore/ops/function/sparse_unary_func.py +14 -12
- mindspore/ops/function/vmap_func.py +6 -5
- mindspore/ops/functional.py +15 -10
- mindspore/ops/op_info_register.py +244 -25
- mindspore/ops/operations/__init__.py +31 -19
- mindspore/ops/operations/_grad_ops.py +71 -7
- mindspore/ops/operations/_inner_ops.py +350 -17
- mindspore/ops/operations/_quant_ops.py +4 -8
- mindspore/ops/operations/_sequence_ops.py +42 -0
- mindspore/ops/operations/array_ops.py +68 -282
- mindspore/ops/operations/comm_ops.py +107 -59
- mindspore/ops/operations/custom_ops.py +94 -70
- mindspore/ops/operations/debug_ops.py +8 -4
- mindspore/ops/operations/image_ops.py +18 -12
- mindspore/ops/operations/inner_ops.py +26 -3
- mindspore/ops/operations/math_ops.py +192 -144
- mindspore/ops/operations/nn_ops.py +857 -489
- mindspore/ops/operations/other_ops.py +0 -22
- mindspore/ops/operations/random_ops.py +53 -111
- mindspore/ops/operations/sparse_ops.py +3 -1
- mindspore/ops/primitive.py +24 -18
- mindspore/parallel/_auto_parallel_context.py +68 -8
- mindspore/parallel/_cost_model_context.py +2 -2
- mindspore/parallel/_offload_context.py +17 -3
- mindspore/parallel/_parallel_serialization.py +12 -5
- mindspore/parallel/_ps_context.py +12 -0
- mindspore/parallel/_tensor.py +18 -13
- mindspore/parallel/_transformer/layers.py +5 -3
- mindspore/parallel/_transformer/loss.py +1 -0
- mindspore/parallel/_transformer/moe.py +2 -2
- mindspore/parallel/_transformer/op_parallel_config.py +12 -1
- mindspore/parallel/_transformer/transformer.py +23 -3
- mindspore/parallel/_utils.py +11 -7
- mindspore/parallel/algo_parameter_config.py +85 -5
- mindspore/parallel/checkpoint_transform.py +19 -12
- mindspore/parallel/shard.py +21 -14
- mindspore/profiler/common/struct_type.py +3 -3
- mindspore/profiler/common/util.py +4 -2
- mindspore/profiler/envprofiling.py +1 -1
- mindspore/profiler/parser/aicpu_data_parser.py +5 -3
- mindspore/profiler/parser/ascend_flops_generator.py +2 -2
- mindspore/profiler/parser/ascend_fpbp_generator.py +1 -1
- mindspore/profiler/parser/ascend_hccl_generator.py +249 -12
- mindspore/profiler/parser/ascend_msprof_exporter.py +150 -255
- mindspore/profiler/parser/ascend_msprof_generator.py +204 -17
- mindspore/profiler/parser/ascend_op_generator.py +6 -6
- mindspore/profiler/parser/ascend_steptrace_generator.py +6 -4
- mindspore/profiler/parser/ascend_timeline_generator.py +14 -187
- mindspore/profiler/parser/base_timeline_generator.py +10 -8
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +16 -12
- mindspore/profiler/parser/flops_parser.py +15 -11
- mindspore/profiler/parser/framework_parser.py +38 -22
- mindspore/profiler/parser/hccl_parser.py +16 -12
- mindspore/profiler/parser/integrator.py +22 -11
- mindspore/profiler/parser/memory_usage_parser.py +2 -2
- mindspore/profiler/parser/minddata_analyzer.py +12 -14
- mindspore/profiler/parser/minddata_pipeline_parser.py +1 -1
- mindspore/profiler/parser/msadvisor_parser.py +8 -4
- mindspore/profiler/parser/op_intermediate_parser.py +5 -2
- mindspore/profiler/parser/optime_parser.py +1 -1
- mindspore/profiler/parser/profiler_info.py +21 -2
- mindspore/profiler/parser/step_trace_parser.py +11 -14
- mindspore/profiler/profiling.py +179 -89
- mindspore/rewrite/api/node.py +102 -19
- mindspore/rewrite/api/node_type.py +5 -1
- mindspore/rewrite/api/pattern_engine.py +1 -1
- mindspore/rewrite/api/scoped_value.py +9 -17
- mindspore/rewrite/api/symbol_tree.py +131 -47
- mindspore/rewrite/ast_helpers/__init__.py +2 -1
- mindspore/rewrite/ast_helpers/ast_finder.py +129 -0
- mindspore/rewrite/ast_helpers/ast_modifier.py +116 -104
- mindspore/rewrite/ast_transformers/flatten_recursive_stmt.py +93 -46
- mindspore/rewrite/common/rewrite_elog.py +5 -1
- mindspore/rewrite/namer.py +33 -24
- mindspore/rewrite/namespace.py +14 -5
- mindspore/{_extends/graph_kernel/expanders/complex → rewrite/node}/__init__.py +9 -9
- mindspore/rewrite/node/call_function.py +79 -0
- mindspore/rewrite/node/cell_container.py +135 -0
- mindspore/rewrite/node/control_flow.py +88 -0
- mindspore/rewrite/{node.py → node/node.py} +273 -234
- mindspore/rewrite/node/node_manager.py +254 -0
- mindspore/rewrite/{topological_manager.py → node/node_topological_manager.py} +13 -46
- mindspore/rewrite/parsers/arguments_parser.py +22 -21
- mindspore/rewrite/parsers/assign_parser.py +216 -221
- mindspore/rewrite/parsers/attribute_parser.py +9 -7
- mindspore/rewrite/parsers/class_def_parser.py +174 -113
- mindspore/rewrite/parsers/constant_parser.py +9 -6
- mindspore/rewrite/parsers/container_parser.py +9 -7
- mindspore/rewrite/parsers/for_parser.py +42 -21
- mindspore/rewrite/parsers/function_def_parser.py +24 -16
- mindspore/rewrite/parsers/if_parser.py +28 -24
- mindspore/rewrite/parsers/module_parser.py +196 -25
- mindspore/rewrite/{parser.py → parsers/parser.py} +4 -2
- mindspore/rewrite/{parser_register.py → parsers/parser_register.py} +1 -1
- mindspore/rewrite/parsers/return_parser.py +6 -6
- mindspore/rewrite/sparsify/sparse_transformer.py +12 -3
- mindspore/rewrite/sparsify/utils.py +1 -1
- mindspore/rewrite/symbol_tree.py +523 -578
- mindspore/rewrite/symbol_tree_builder.py +9 -193
- mindspore/rewrite/symbol_tree_dumper.py +2 -2
- mindspore/run_check/_check_version.py +6 -4
- mindspore/{ops/bprop_mindir → safeguard}/__init__.py +4 -3
- mindspore/safeguard/rewrite_obfuscation.py +541 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +7 -3
- mindspore/train/amp.py +323 -123
- mindspore/train/anf_ir_pb2.py +14 -2
- mindspore/train/callback/_backup_and_restore.py +2 -12
- mindspore/train/callback/_callback.py +29 -4
- mindspore/train/callback/_checkpoint.py +23 -8
- mindspore/train/callback/_early_stop.py +2 -2
- mindspore/train/callback/_landscape.py +4 -4
- mindspore/train/callback/_loss_monitor.py +2 -2
- mindspore/train/callback/_on_request_exit.py +2 -2
- mindspore/train/callback/_reduce_lr_on_plateau.py +3 -4
- mindspore/train/callback/_summary_collector.py +15 -8
- mindspore/train/callback/_time_monitor.py +58 -5
- mindspore/train/data_sink.py +5 -11
- mindspore/train/dataset_helper.py +84 -57
- mindspore/train/loss_scale_manager.py +2 -2
- mindspore/train/metrics/__init__.py +3 -3
- mindspore/train/metrics/cosine_similarity.py +1 -1
- mindspore/train/metrics/hausdorff_distance.py +3 -2
- mindspore/train/metrics/mean_surface_distance.py +3 -2
- mindspore/train/metrics/metric.py +39 -19
- mindspore/train/metrics/roc.py +2 -2
- mindspore/train/metrics/root_mean_square_surface_distance.py +4 -3
- mindspore/train/mind_ir_pb2.py +85 -36
- mindspore/train/model.py +187 -47
- mindspore/train/serialization.py +487 -161
- mindspore/train/summary/_summary_adapter.py +1 -1
- mindspore/train/summary/_writer_pool.py +3 -2
- mindspore/train/summary/summary_record.py +37 -17
- mindspore/train/train_thor/convert_utils.py +3 -3
- mindspore/train/train_thor/dataset_helper.py +1 -1
- mindspore/turbojpeg.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/METADATA +7 -4
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/RECORD +406 -463
- mindspore/_extends/graph_kernel/expander.py +0 -80
- mindspore/_extends/graph_kernel/expanders/__init__.py +0 -54
- mindspore/_extends/graph_kernel/expanders/_utils.py +0 -269
- mindspore/_extends/graph_kernel/expanders/addn.py +0 -33
- mindspore/_extends/graph_kernel/expanders/batchnorm.py +0 -152
- mindspore/_extends/graph_kernel/expanders/batchnorm_grad.py +0 -105
- mindspore/_extends/graph_kernel/expanders/clip_by_norm_no_div_sum.py +0 -33
- mindspore/_extends/graph_kernel/expanders/complex/abs.py +0 -30
- mindspore/_extends/graph_kernel/expanders/complex/add.py +0 -44
- mindspore/_extends/graph_kernel/expanders/complex/div.py +0 -62
- mindspore/_extends/graph_kernel/expanders/complex/mul.py +0 -52
- mindspore/_extends/graph_kernel/expanders/complex/real_div.py +0 -62
- mindspore/_extends/graph_kernel/expanders/complex/sub.py +0 -45
- mindspore/_extends/graph_kernel/expanders/conv2d.py +0 -200
- mindspore/_extends/graph_kernel/expanders/dropout_grad.py +0 -30
- mindspore/_extends/graph_kernel/expanders/equal_count.py +0 -50
- mindspore/_extends/graph_kernel/expanders/erfc.py +0 -35
- mindspore/_extends/graph_kernel/expanders/expand_dims.py +0 -50
- mindspore/_extends/graph_kernel/expanders/fused_adam.py +0 -44
- mindspore/_extends/graph_kernel/expanders/fused_adam_weight_decay.py +0 -47
- mindspore/_extends/graph_kernel/expanders/fused_mul_add.py +0 -28
- mindspore/_extends/graph_kernel/expanders/gelu_grad.py +0 -70
- mindspore/_extends/graph_kernel/expanders/gkdropout.py +0 -40
- mindspore/_extends/graph_kernel/expanders/identity.py +0 -25
- mindspore/_extends/graph_kernel/expanders/layernorm.py +0 -93
- mindspore/_extends/graph_kernel/expanders/layernorm_grad.py +0 -113
- mindspore/_extends/graph_kernel/expanders/logsoftmax.py +0 -46
- mindspore/_extends/graph_kernel/expanders/logsoftmax_grad.py +0 -36
- mindspore/_extends/graph_kernel/expanders/matmul.py +0 -80
- mindspore/_extends/graph_kernel/expanders/maximum_grad.py +0 -59
- mindspore/_extends/graph_kernel/expanders/minimum_grad.py +0 -80
- mindspore/_extends/graph_kernel/expanders/oneslike.py +0 -26
- mindspore/_extends/graph_kernel/expanders/reduce_mean.py +0 -43
- mindspore/_extends/graph_kernel/expanders/relu_grad.py +0 -32
- mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits.py +0 -41
- mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits_grad.py +0 -35
- mindspore/_extends/graph_kernel/expanders/sigmoid_grad.py +0 -31
- mindspore/_extends/graph_kernel/expanders/slice.py +0 -35
- mindspore/_extends/graph_kernel/expanders/softmax_cross_entropy_with_logits.py +0 -42
- mindspore/_extends/graph_kernel/expanders/softmax_grad_ext.py +0 -41
- mindspore/_extends/graph_kernel/expanders/softsign.py +0 -28
- mindspore/_extends/graph_kernel/expanders/sqrt_grad.py +0 -29
- mindspore/_extends/graph_kernel/expanders/square_sum_all.py +0 -44
- mindspore/_extends/graph_kernel/expanders/square_sum_v1.py +0 -37
- mindspore/_extends/graph_kernel/expanders/squared_difference.py +0 -43
- mindspore/_extends/graph_kernel/expanders/tanh_grad.py +0 -31
- mindspore/_extends/graph_kernel/model/op_infer.py +0 -506
- mindspore/dataset/datapreprocess/__init__.py +0 -20
- mindspore/dataset/datapreprocess/preprocess_imagenet_validate_dataset.py +0 -54
- mindspore/include/api/net.h +0 -142
- mindspore/nn/lr_scheduler.py +0 -262
- mindspore/ops/_grad_experimental/grad_image_ops.py +0 -248
- mindspore/ops/_grad_experimental/grad_linalg_ops.py +0 -181
- mindspore/ops/_grad_experimental/grad_other_ops.py +0 -72
- mindspore/ops/_grad_experimental/grad_scalar_ops.py +0 -112
- mindspore/ops/_grad_experimental/grad_sequence_ops.py +0 -351
- mindspore/ops/_op_impl/_custom_op/flash_attention/__init__.py +0 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/attention.py +0 -350
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_bwd.py +0 -409
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_fwd.py +0 -578
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_impl.py +0 -199
- mindspore/ops/_op_impl/_custom_op/flash_attention/tik_ops_utils.py +0 -446
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/__init__.py +0 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/sparse_tiling.py +0 -45
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/strategy.py +0 -67
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/wukong_tiling.py +0 -62
- mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Broadcast_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Depend_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DepthwiseConv2dNative_bprop.mindir +0 -138
- mindspore/ops/bprop_mindir/EmbeddingLookup_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Load_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ScatterNonAliasingAdd_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SparseGatherV2_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SparseSoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Switch_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TransShape_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Unique_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Unstack_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/generate_mindir.py +0 -114
- mindspore/rewrite/node_visitor.py +0 -44
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/WHEEL +0 -0
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/entry_points.txt +0 -0
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/top_level.txt +0 -0
mindspore/train/anf_ir_pb2.py
CHANGED
|
@@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
|
|
|
20
20
|
syntax='proto2',
|
|
21
21
|
serialized_options=None,
|
|
22
22
|
create_key=_descriptor._internal_create_key,
|
|
23
|
-
serialized_pb=b'\n\x0c\x61nf_ir.proto\x12\x0emindspore.irpb\"\xdb\x04\n\nValueProto\x12\'\n\x05\x64type\x18\x01 \x01(\x0e\x32\x18.mindspore.irpb.DataType\x12\x10\n\x08\x62ool_val\x18\x02 \x01(\x08\x12\x0f\n\x07int_val\x18\x03 \x01(\x03\x12\x10\n\x08uint_val\x18\x04 \x01(\x04\x12\x11\n\tfloat_val\x18\x05 \x01(\x02\x12\x12\n\ndouble_val\x18\x06 \x01(\x01\x12\x0f\n\x07str_val\x18\x07 \x01(\t\x12/\n\ntensor_val\x18\x08 \x01(\x0b\x32\x1b.mindspore.irpb.TensorProto\x12)\n\x05graph\x18\t \x01(\x0b\x32\x1a.mindspore.irpb.GraphProto\x12\x11\n\tbool_vals\x18\n \x03(\x08\x12\x10\n\x08int_vals\x18\x0b \x03(\x03\x12\x11\n\tuint_vals\x18\x0c \x03(\x04\x12\x12\n\nfloat_vals\x18\r \x03(\x02\x12\x13\n\x0b\x64ouble_vals\x18\x0e \x03(\x01\x12\x10\n\x08str_vals\x18\x0f \x03(\t\x12\x30\n\x0btensor_vals\x18\x10 \x03(\x0b\x32\x1b.mindspore.irpb.TensorProto\x12*\n\x06graphs\x18\x11 \x03(\x0b\x32\x1a.mindspore.irpb.GraphProto\x12*\n\x06values\x18\x12 \x03(\x0b\x32\x1a.mindspore.irpb.ValueProto\x12\x31\n\x08\x64ict_val\x18\x13 \x03(\x0b\x32\x1f.mindspore.irpb.NamedValueProto\x12+\n\x08type_val\x18\x14 \x01(\x0b\x32\x19.mindspore.irpb.TypeProto\"I\n\x0e\x41ttributeProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12)\n\x05value\x18\x02 \x01(\x0b\x32\x1a.mindspore.irpb.ValueProto\"I\n\x0fNamedValueProto\x12\x0b\n\x03key\x18\x01 \x01(\t\x12)\n\x05value\x18\x02 \x01(\x0b\x32\x1a.mindspore.irpb.ValueProto\"t\n\x10TensorShapeProto\x12\x37\n\x03\x64im\x18\x01 \x03(\x0b\x32*.mindspore.irpb.TensorShapeProto.Dimension\x1a\'\n\tDimension\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\t\"\xda\x02\n\tTypeProto\x12+\n\tdata_type\x18\x01 \x01(\x0e\x32\x18.mindspore.irpb.DataType\x12\x37\n\x0btensor_type\x18\x02 \x01(\x0b\x32 .mindspore.irpb.TypeProto.TensorH\x00\x12;\n\rsequence_type\x18\x03 \x01(\x0b\x32\".mindspore.irpb.TypeProto.SequenceH\x00\x1a\x66\n\x06Tensor\x12+\n\telem_type\x18\x01 \x01(\x0e\x32\x18.mindspore.irpb.DataType\x12/\n\x05shape\x18\x02 \x01(\x0b\x32 .mindspore.irpb.TensorShapeProto\x1a\x39\n\x08Sequence\x12-\n\nelem_types\x18\x01 \x03(\x0b\x32\x19.mindspore.irpb.TypeProtoB\x07\n\x05value\"x\n\x0eParameterProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\'\n\x04type\x18\x02 \x01(\x0b\x32\x19.mindspore.irpb.TypeProto\x12/\n\x0b\x64\x65\x66\x61ult_val\x18\x03 \x01(\x0b\x32\x1a.mindspore.irpb.ValueProto\"D\n\x0bOutputProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\'\n\x04type\x18\x02 \x01(\x0b\x32\x19.mindspore.irpb.TypeProto\"z\n\nInputProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x31\n\x04type\x18\x02 \x01(\x0e\x32#.mindspore.irpb.InputProto.EdgeType\"+\n\x08\x45\x64geType\x12\r\n\tDATA_EDGE\x10\x00\x12\x10\n\x0c\x43ONTROL_EDGE\x10\x01\"\x83\x02\n\tNodeProto\x12)\n\x05input\x18\x01 \x03(\x0b\x32\x1a.mindspore.irpb.InputProto\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0f\n\x07op_type\x18\x03 \x01(\t\x12\r\n\x05scope\x18\x04 \x01(\t\x12\x31\n\tattribute\x18\x05 \x03(\x0b\x32\x1e.mindspore.irpb.AttributeProto\x12.\n\x0boutput_type\x18\x06 \x01(\x0b\x32\x19.mindspore.irpb.TypeProto\x12\x10\n\x08output_i\x18\x07 \x01(\x04\x12\x11\n\tfull_name\x18\x08 \x01(\t\x12\x15\n\rinstance_name\x18\n \x01(\t\"\xb0\x01\n\nModelProto\x12\x12\n\nir_version\x18\x01 \x01(\x03\x12\x0e\n\x06\x64omain\x18\x02 \x01(\t\x12\x15\n\rmodel_version\x18\x03 \x01(\x03\x12)\n\x05graph\x18\x04 \x01(\x0b\x32\x1a.mindspore.irpb.GraphProto\x12<\n\x12metadata_operators\x18\x05 \x01(\x0b\x32 .mindspore.irpb.OperatorSetProto\"?\n\rOperatorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x63onfig\x18\x02 \x01(\x0c\x12\x10\n\x08obj_info\x18\x03 \x01(\x0c\"U\n\x10OperatorSetProto\x12\x30\n\toperators\x18\x01 \x03(\x0b\x32\x1d.mindspore.irpb.OperatorProto\x12\x0f\n\x07summary\x18\x02 \x01(\t\"\xda\x01\n\nGraphProto\x12\'\n\x04node\x18\x01 \x03(\x0b\x32\x19.mindspore.irpb.NodeProto\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x32\n\nparameters\x18\x03 \x03(\x0b\x32\x1e.mindspore.irpb.ParameterProto\x12,\n\x07outputs\x18\x04 \x03(\x0b\x32\x1b.mindspore.irpb.OutputProto\x12\x33\n\nconst_vals\x18\x05 \x03(\x0b\x32\x1f.mindspore.irpb.NamedValueProto\"\xd4\x01\n\x0bTensorProto\x12\x0c\n\x04\x64ims\x18\x01 \x03(\x03\x12+\n\tdata_type\x18\x02 \x01(\x0e\x32\x18.mindspore.irpb.DataType\x12\x16\n\nfloat_data\x18\x03 \x03(\x02\x42\x02\x10\x01\x12\x16\n\nint32_data\x18\x04 \x03(\x05\x42\x02\x10\x01\x12\x16\n\nint64_data\x18\x05 \x03(\x03\x42\x02\x10\x01\x12\x17\n\x0b\x64ouble_data\x18\x06 \x03(\x01\x42\x02\x10\x01\x12\x17\n\x0buint64_data\x18\x07 \x03(\x04\x42\x02\x10\x01\x12\x10\n\x08raw_data\x18\x08 \x01(\x0c*/\n\x07Version\x12\x14\n\x10UNKNOWWN_VERSION\x10\x00\x12\x0e\n\nIR_VERSION\x10\x01*\
|
|
23
|
+
serialized_pb=b'\n\x0c\x61nf_ir.proto\x12\x0emindspore.irpb\"\xdb\x04\n\nValueProto\x12\'\n\x05\x64type\x18\x01 \x01(\x0e\x32\x18.mindspore.irpb.DataType\x12\x10\n\x08\x62ool_val\x18\x02 \x01(\x08\x12\x0f\n\x07int_val\x18\x03 \x01(\x03\x12\x10\n\x08uint_val\x18\x04 \x01(\x04\x12\x11\n\tfloat_val\x18\x05 \x01(\x02\x12\x12\n\ndouble_val\x18\x06 \x01(\x01\x12\x0f\n\x07str_val\x18\x07 \x01(\t\x12/\n\ntensor_val\x18\x08 \x01(\x0b\x32\x1b.mindspore.irpb.TensorProto\x12)\n\x05graph\x18\t \x01(\x0b\x32\x1a.mindspore.irpb.GraphProto\x12\x11\n\tbool_vals\x18\n \x03(\x08\x12\x10\n\x08int_vals\x18\x0b \x03(\x03\x12\x11\n\tuint_vals\x18\x0c \x03(\x04\x12\x12\n\nfloat_vals\x18\r \x03(\x02\x12\x13\n\x0b\x64ouble_vals\x18\x0e \x03(\x01\x12\x10\n\x08str_vals\x18\x0f \x03(\t\x12\x30\n\x0btensor_vals\x18\x10 \x03(\x0b\x32\x1b.mindspore.irpb.TensorProto\x12*\n\x06graphs\x18\x11 \x03(\x0b\x32\x1a.mindspore.irpb.GraphProto\x12*\n\x06values\x18\x12 \x03(\x0b\x32\x1a.mindspore.irpb.ValueProto\x12\x31\n\x08\x64ict_val\x18\x13 \x03(\x0b\x32\x1f.mindspore.irpb.NamedValueProto\x12+\n\x08type_val\x18\x14 \x01(\x0b\x32\x19.mindspore.irpb.TypeProto\"I\n\x0e\x41ttributeProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12)\n\x05value\x18\x02 \x01(\x0b\x32\x1a.mindspore.irpb.ValueProto\"I\n\x0fNamedValueProto\x12\x0b\n\x03key\x18\x01 \x01(\t\x12)\n\x05value\x18\x02 \x01(\x0b\x32\x1a.mindspore.irpb.ValueProto\"t\n\x10TensorShapeProto\x12\x37\n\x03\x64im\x18\x01 \x03(\x0b\x32*.mindspore.irpb.TensorShapeProto.Dimension\x1a\'\n\tDimension\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\t\"\xda\x02\n\tTypeProto\x12+\n\tdata_type\x18\x01 \x01(\x0e\x32\x18.mindspore.irpb.DataType\x12\x37\n\x0btensor_type\x18\x02 \x01(\x0b\x32 .mindspore.irpb.TypeProto.TensorH\x00\x12;\n\rsequence_type\x18\x03 \x01(\x0b\x32\".mindspore.irpb.TypeProto.SequenceH\x00\x1a\x66\n\x06Tensor\x12+\n\telem_type\x18\x01 \x01(\x0e\x32\x18.mindspore.irpb.DataType\x12/\n\x05shape\x18\x02 \x01(\x0b\x32 .mindspore.irpb.TensorShapeProto\x1a\x39\n\x08Sequence\x12-\n\nelem_types\x18\x01 \x03(\x0b\x32\x19.mindspore.irpb.TypeProtoB\x07\n\x05value\"x\n\x0eParameterProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\'\n\x04type\x18\x02 \x01(\x0b\x32\x19.mindspore.irpb.TypeProto\x12/\n\x0b\x64\x65\x66\x61ult_val\x18\x03 \x01(\x0b\x32\x1a.mindspore.irpb.ValueProto\"D\n\x0bOutputProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\'\n\x04type\x18\x02 \x01(\x0b\x32\x19.mindspore.irpb.TypeProto\"z\n\nInputProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x31\n\x04type\x18\x02 \x01(\x0e\x32#.mindspore.irpb.InputProto.EdgeType\"+\n\x08\x45\x64geType\x12\r\n\tDATA_EDGE\x10\x00\x12\x10\n\x0c\x43ONTROL_EDGE\x10\x01\"\x83\x02\n\tNodeProto\x12)\n\x05input\x18\x01 \x03(\x0b\x32\x1a.mindspore.irpb.InputProto\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0f\n\x07op_type\x18\x03 \x01(\t\x12\r\n\x05scope\x18\x04 \x01(\t\x12\x31\n\tattribute\x18\x05 \x03(\x0b\x32\x1e.mindspore.irpb.AttributeProto\x12.\n\x0boutput_type\x18\x06 \x01(\x0b\x32\x19.mindspore.irpb.TypeProto\x12\x10\n\x08output_i\x18\x07 \x01(\x04\x12\x11\n\tfull_name\x18\x08 \x01(\t\x12\x15\n\rinstance_name\x18\n \x01(\t\"\xb0\x01\n\nModelProto\x12\x12\n\nir_version\x18\x01 \x01(\x03\x12\x0e\n\x06\x64omain\x18\x02 \x01(\t\x12\x15\n\rmodel_version\x18\x03 \x01(\x03\x12)\n\x05graph\x18\x04 \x01(\x0b\x32\x1a.mindspore.irpb.GraphProto\x12<\n\x12metadata_operators\x18\x05 \x01(\x0b\x32 .mindspore.irpb.OperatorSetProto\"?\n\rOperatorProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x63onfig\x18\x02 \x01(\x0c\x12\x10\n\x08obj_info\x18\x03 \x01(\x0c\"U\n\x10OperatorSetProto\x12\x30\n\toperators\x18\x01 \x03(\x0b\x32\x1d.mindspore.irpb.OperatorProto\x12\x0f\n\x07summary\x18\x02 \x01(\t\"\xda\x01\n\nGraphProto\x12\'\n\x04node\x18\x01 \x03(\x0b\x32\x19.mindspore.irpb.NodeProto\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x32\n\nparameters\x18\x03 \x03(\x0b\x32\x1e.mindspore.irpb.ParameterProto\x12,\n\x07outputs\x18\x04 \x03(\x0b\x32\x1b.mindspore.irpb.OutputProto\x12\x33\n\nconst_vals\x18\x05 \x03(\x0b\x32\x1f.mindspore.irpb.NamedValueProto\"\xd4\x01\n\x0bTensorProto\x12\x0c\n\x04\x64ims\x18\x01 \x03(\x03\x12+\n\tdata_type\x18\x02 \x01(\x0e\x32\x18.mindspore.irpb.DataType\x12\x16\n\nfloat_data\x18\x03 \x03(\x02\x42\x02\x10\x01\x12\x16\n\nint32_data\x18\x04 \x03(\x05\x42\x02\x10\x01\x12\x16\n\nint64_data\x18\x05 \x03(\x03\x42\x02\x10\x01\x12\x17\n\x0b\x64ouble_data\x18\x06 \x03(\x01\x42\x02\x10\x01\x12\x17\n\x0buint64_data\x18\x07 \x03(\x04\x42\x02\x10\x01\x12\x10\n\x08raw_data\x18\x08 \x01(\x0c*/\n\x07Version\x12\x14\n\x10UNKNOWWN_VERSION\x10\x00\x12\x0e\n\nIR_VERSION\x10\x01*\xee\x05\n\x08\x44\x61taType\x12\x10\n\x0c\x44T_UNDEFINED\x10\x00\x12\x0b\n\x07\x44T_BOOL\x10\x01\x12\x0b\n\x07\x44T_INT8\x10\x02\x12\x0c\n\x08\x44T_INT16\x10\x03\x12\x0c\n\x08\x44T_INT32\x10\x04\x12\x0c\n\x08\x44T_INT64\x10\x05\x12\x0c\n\x08\x44T_UINT8\x10\x06\x12\r\n\tDT_UINT16\x10\x07\x12\r\n\tDT_UINT32\x10\x08\x12\r\n\tDT_UINT64\x10\t\x12\x0e\n\nDT_FLOAT16\x10\n\x12\x0e\n\nDT_FLOAT32\x10\x0b\x12\x0e\n\nDT_FLOAT64\x10\x0c\x12\r\n\tDT_STRING\x10\r\x12\r\n\tDT_TENSOR\x10\x0e\x12\x0c\n\x08\x44T_GRAPH\x10\x0f\x12\x0c\n\x08\x44T_BOOLS\x10\x10\x12\x0c\n\x08\x44T_INTS8\x10\x11\x12\r\n\tDT_INTS16\x10\x12\x12\r\n\tDT_INTS32\x10\x13\x12\r\n\tDT_INTS64\x10\x14\x12\r\n\tDT_UINTS8\x10\x15\x12\x0e\n\nDT_UINTS16\x10\x16\x12\x0e\n\nDT_UINTS32\x10\x17\x12\x0e\n\nDT_UINTS64\x10\x18\x12\x0f\n\x0b\x44T_FLOATS16\x10\x19\x12\x0f\n\x0b\x44T_FLOATS32\x10\x1a\x12\x0f\n\x0b\x44T_FLOATS64\x10\x1b\x12\x0e\n\nDT_STRINGS\x10\x1c\x12\x0e\n\nDT_TENSORS\x10\x1d\x12\r\n\tDT_GRAPHS\x10\x1e\x12\x0c\n\x08\x44T_TUPLE\x10\x1f\x12\x0b\n\x07\x44T_LIST\x10 \x12\x0b\n\x07\x44T_DICT\x10!\x12\x0b\n\x07\x44T_NONE\x10\"\x12\x0f\n\x0b\x44T_SYM_INST\x10#\x12\x0f\n\x0b\x44T_BASE_INT\x10$\x12\x10\n\x0c\x44T_BASE_UINT\x10%\x12\x11\n\rDT_BASE_FLOAT\x10&\x12\x0b\n\x07\x44T_TYPE\x10\'\x12\n\n\x06\x44T_ANY\x10(\x12\r\n\tDT_REFKEY\x10)\x12\n\n\x06\x44T_REF\x10*\x12\x10\n\x0c\x44T_COMPLEX64\x10+\x12\x11\n\rDT_COMPLEX128\x10,\x12\x13\n\x0f\x44T_BASE_COMPLEX\x10-\x12\x0f\n\x0b\x44T_BFLOAT16\x10.\x12\x10\n\x0c\x44T_BFLOATS16\x10/'
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
_VERSION = _descriptor.EnumDescriptor(
|
|
@@ -286,11 +286,21 @@ _DATATYPE = _descriptor.EnumDescriptor(
|
|
|
286
286
|
serialized_options=None,
|
|
287
287
|
type=None,
|
|
288
288
|
create_key=_descriptor._internal_create_key),
|
|
289
|
+
_descriptor.EnumValueDescriptor(
|
|
290
|
+
name='DT_BFLOAT16', index=46, number=46,
|
|
291
|
+
serialized_options=None,
|
|
292
|
+
type=None,
|
|
293
|
+
create_key=_descriptor._internal_create_key),
|
|
294
|
+
_descriptor.EnumValueDescriptor(
|
|
295
|
+
name='DT_BFLOATS16', index=47, number=47,
|
|
296
|
+
serialized_options=None,
|
|
297
|
+
type=None,
|
|
298
|
+
create_key=_descriptor._internal_create_key),
|
|
289
299
|
],
|
|
290
300
|
containing_type=None,
|
|
291
301
|
serialized_options=None,
|
|
292
302
|
serialized_start=2650,
|
|
293
|
-
serialized_end=
|
|
303
|
+
serialized_end=3400,
|
|
294
304
|
)
|
|
295
305
|
_sym_db.RegisterEnumDescriptor(_DATATYPE)
|
|
296
306
|
|
|
@@ -343,6 +353,8 @@ DT_REF = 42
|
|
|
343
353
|
DT_COMPLEX64 = 43
|
|
344
354
|
DT_COMPLEX128 = 44
|
|
345
355
|
DT_BASE_COMPLEX = 45
|
|
356
|
+
DT_BFLOAT16 = 46
|
|
357
|
+
DT_BFLOATS16 = 47
|
|
346
358
|
|
|
347
359
|
|
|
348
360
|
_INPUTPROTO_EDGETYPE = _descriptor.EnumDescriptor(
|
|
@@ -50,25 +50,15 @@ class BackupAndRestore(Callback):
|
|
|
50
50
|
>>> from mindspore.train import Model, BackupAndRestore, RunContext
|
|
51
51
|
>>>
|
|
52
52
|
>>> # Define the network structure of LeNet5. Refer to
|
|
53
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
53
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
54
54
|
>>> net = LeNet5()
|
|
55
55
|
>>> loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction='mean')
|
|
56
56
|
>>> optim = nn.Momentum(net.trainable_params(), 0.01, 0.9)
|
|
57
57
|
>>> model = Model(net, loss_fn=loss, optimizer=optim)
|
|
58
58
|
>>> # Create the dataset taking MNIST as an example. Refer to
|
|
59
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
59
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
60
60
|
>>> dataset = create_dataset()
|
|
61
61
|
>>> backup_ckpt = BackupAndRestore("backup")
|
|
62
|
-
>>> cb_params = {}
|
|
63
|
-
>>> cb_params["cur_epoch_num"] = 4
|
|
64
|
-
>>> cb_params["epoch_num"] = 4
|
|
65
|
-
>>> cb_params["cur_step_num"] = 2
|
|
66
|
-
>>> cb_params["batch_num"] = 2
|
|
67
|
-
>>> cb_params["net_outputs"] = Tensor(2.0)
|
|
68
|
-
>>> run_context = RunContext(cb_params)
|
|
69
|
-
>>> backup_ckpt.on_train_begin(run_context)
|
|
70
|
-
>>> backup_ckpt.on_train_epoch_end(run_context)
|
|
71
|
-
>>> backup_ckpt.on_train_end(run_context)
|
|
72
62
|
>>> model.train(10, dataset, callbacks=backup_ckpt)
|
|
73
63
|
"""
|
|
74
64
|
def __init__(self, backup_dir, save_freq="epoch", delete_checkpoint=True):
|
|
@@ -123,7 +123,8 @@ class Callback:
|
|
|
123
123
|
recording current attributes. Users can add custimized attributes to the information.
|
|
124
124
|
Training process can also be stopped by calling `request_stop` method. For details
|
|
125
125
|
of custom Callback, please check
|
|
126
|
-
`Callback
|
|
126
|
+
`Callback tutorial <https://www.mindspore.cn/tutorials/en/r2.2/advanced/model/
|
|
127
|
+
callback.html#customized-callback-mechanism>`_.
|
|
127
128
|
|
|
128
129
|
Examples:
|
|
129
130
|
>>> import numpy as np
|
|
@@ -159,6 +160,10 @@ class Callback:
|
|
|
159
160
|
Called once before the network executing.
|
|
160
161
|
A backwards compatibility alias for `on_train_begin` and `on_eval_begin`.
|
|
161
162
|
|
|
163
|
+
Note:
|
|
164
|
+
`begin` is deprecated and will be deleted in a future version,
|
|
165
|
+
please use `on_train_begin` and `on_eval_begin` instead.
|
|
166
|
+
|
|
162
167
|
Args:
|
|
163
168
|
run_context (RunContext): Include some information of the model.
|
|
164
169
|
"""
|
|
@@ -168,6 +173,10 @@ class Callback:
|
|
|
168
173
|
Called before each epoch beginning.
|
|
169
174
|
A backwards compatibility alias for `on_train_epoch_begin` and `on_eval_epoch_begin`.
|
|
170
175
|
|
|
176
|
+
Note:
|
|
177
|
+
`epoch_begin` is deprecated and will be deleted in a future version,
|
|
178
|
+
please use `on_train_epoch_begin` and `on_eval_epoch_begin` instead.
|
|
179
|
+
|
|
171
180
|
Args:
|
|
172
181
|
run_context (RunContext): Include some information of the model.
|
|
173
182
|
"""
|
|
@@ -177,6 +186,10 @@ class Callback:
|
|
|
177
186
|
Called after each epoch finished.
|
|
178
187
|
A backwards compatibility alias for `on_train_epoch_end` and `on_eval_epoch_end`.
|
|
179
188
|
|
|
189
|
+
Note:
|
|
190
|
+
`epoch_end` is deprecated and will be deleted in a future version,
|
|
191
|
+
please use `on_train_epoch_end` and `on_eval_epoch_end` instead.
|
|
192
|
+
|
|
180
193
|
Args:
|
|
181
194
|
run_context (RunContext): Include some information of the model.
|
|
182
195
|
"""
|
|
@@ -186,6 +199,10 @@ class Callback:
|
|
|
186
199
|
Called before each step beginning.
|
|
187
200
|
A backwards compatibility alias for `on_train_step_begin` and `on_eval_step_begin`.
|
|
188
201
|
|
|
202
|
+
Note:
|
|
203
|
+
`step_begin` is deprecated and will be deleted in a future version,
|
|
204
|
+
please use `on_train_step_begin` and `on_eval_step_begin` instead.
|
|
205
|
+
|
|
189
206
|
Args:
|
|
190
207
|
run_context (RunContext): Include some information of the model.
|
|
191
208
|
"""
|
|
@@ -195,6 +212,10 @@ class Callback:
|
|
|
195
212
|
Called after each step finished.
|
|
196
213
|
A backwards compatibility alias for `on_train_step_end` and `on_eval_step_end`.
|
|
197
214
|
|
|
215
|
+
Note:
|
|
216
|
+
`step_end` is deprecated and will be deleted in a future version,
|
|
217
|
+
please use `on_train_step_end` and `on_eval_step_end` instead.
|
|
218
|
+
|
|
198
219
|
Args:
|
|
199
220
|
run_context (RunContext): Include some information of the model.
|
|
200
221
|
"""
|
|
@@ -204,6 +225,10 @@ class Callback:
|
|
|
204
225
|
Called once after network training.
|
|
205
226
|
A backwards compatibility alias for `on_train_end` and `on_eval_end`.
|
|
206
227
|
|
|
228
|
+
Note:
|
|
229
|
+
`end` is deprecated and will be deleted in a future version,
|
|
230
|
+
please use `on_train_end` and `on_eval_end` instead.
|
|
231
|
+
|
|
207
232
|
Args:
|
|
208
233
|
run_context (RunContext): Include some information of the model.
|
|
209
234
|
"""
|
|
@@ -468,7 +493,7 @@ class RunContext:
|
|
|
468
493
|
`RunContext.original_args()` and add extra attributes to the information, but also can stop the
|
|
469
494
|
training process by calling `request_stop` method. For details of custom Callback,
|
|
470
495
|
please check
|
|
471
|
-
`Callback Mechanism <https://www.mindspore.cn/tutorials/en/r2.
|
|
496
|
+
`Callback Mechanism <https://www.mindspore.cn/tutorials/en/r2.2/advanced/model/callback.html>`_.
|
|
472
497
|
|
|
473
498
|
`RunContext.original_args()` holds the model context information as a dictionary variable, and
|
|
474
499
|
different attributes of the dictionary are stored in training or eval process. Details are as follows:
|
|
@@ -550,7 +575,7 @@ class RunContext:
|
|
|
550
575
|
|
|
551
576
|
Tutorial Examples:
|
|
552
577
|
- `Callback Mechanism - Customized Callback Mechanism
|
|
553
|
-
<https://mindspore.cn/tutorials/en/r2.
|
|
578
|
+
<https://mindspore.cn/tutorials/en/r2.2/advanced/model/callback.html#customized-callback-mechanism>`_
|
|
554
579
|
"""
|
|
555
580
|
return self._original_args
|
|
556
581
|
|
|
@@ -563,7 +588,7 @@ class RunContext:
|
|
|
563
588
|
|
|
564
589
|
Tutorial Examples:
|
|
565
590
|
- `Callback Mechanism - Customized Training Termination Time
|
|
566
|
-
<https://mindspore.cn/tutorials/en/r2.
|
|
591
|
+
<https://mindspore.cn/tutorials/en/r2.2/advanced/model/callback.html#
|
|
567
592
|
customized-training-termination-time>`_
|
|
568
593
|
"""
|
|
569
594
|
self._stop_requested = True
|
|
@@ -62,7 +62,7 @@ def _chg_ckpt_file_name_if_same_exist(directory, prefix, exception=False):
|
|
|
62
62
|
suffix_num = max(suffix_num, int(num)+1)
|
|
63
63
|
|
|
64
64
|
if suffix_num != 0:
|
|
65
|
-
prefix = prefix
|
|
65
|
+
prefix = f'{prefix}_{suffix_num}'
|
|
66
66
|
|
|
67
67
|
return prefix
|
|
68
68
|
|
|
@@ -94,8 +94,8 @@ class CheckpointConfig:
|
|
|
94
94
|
async_save (bool): Whether asynchronous execution saves the checkpoint to a file. Default: ``False`` .
|
|
95
95
|
saved_network (Cell): Network to be saved in checkpoint file. If the saved_network has no relation
|
|
96
96
|
with the network in training, the initial value of saved_network will be saved. Default: ``None`` .
|
|
97
|
-
append_info (list): The information save to checkpoint file. Support "epoch_num", "step_num" and
|
|
98
|
-
of dict must be str, the value of dict must be one of int, float, bool, Parameter or Tensor.
|
|
97
|
+
append_info (list): The information save to checkpoint file. Support "epoch_num", "step_num" and
|
|
98
|
+
dict. The key of dict must be str, the value of dict must be one of int, float, bool, Parameter or Tensor.
|
|
99
99
|
Default: ``None`` .
|
|
100
100
|
enc_key (Union[None, bytes]): Byte type key used for encryption. If the value is None, the encryption
|
|
101
101
|
is not required. Default: ``None`` .
|
|
@@ -104,8 +104,6 @@ class CheckpointConfig:
|
|
|
104
104
|
exception_save (bool): Whether to save the current checkpoint when an exception occurs. Default: ``False`` .
|
|
105
105
|
kwargs (dict): Configuration options dictionary.
|
|
106
106
|
|
|
107
|
-
- incremental (bool): whether export checkpoint for MapParameter incrementally.
|
|
108
|
-
|
|
109
107
|
Raises:
|
|
110
108
|
ValueError: If input parameter is not the correct type.
|
|
111
109
|
|
|
@@ -114,13 +112,13 @@ class CheckpointConfig:
|
|
|
114
112
|
>>> from mindspore.train import Model, CheckpointConfig, ModelCheckpoint
|
|
115
113
|
>>>
|
|
116
114
|
>>> # Define the network structure of LeNet5. Refer to
|
|
117
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
115
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
118
116
|
>>> net = LeNet5()
|
|
119
117
|
>>> loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction='mean')
|
|
120
118
|
>>> optim = nn.Momentum(net.trainable_params(), 0.01, 0.9)
|
|
121
119
|
>>> model = Model(net, loss_fn=loss, optimizer=optim)
|
|
122
120
|
>>> # Create the dataset taking MNIST as an example. Refer to
|
|
123
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
121
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
124
122
|
>>> dataset = create_dataset()
|
|
125
123
|
>>> config = CheckpointConfig(save_checkpoint_seconds=100, keep_checkpoint_per_n_minutes=5, saved_network=net)
|
|
126
124
|
>>> config.save_checkpoint_steps
|
|
@@ -387,6 +385,21 @@ class ModelCheckpoint(Callback):
|
|
|
387
385
|
ValueError: If `prefix` is not str or contains the '/' character.
|
|
388
386
|
ValueError: If `directory` is not str.
|
|
389
387
|
TypeError: If the config is not CheckpointConfig type.
|
|
388
|
+
|
|
389
|
+
Examples:
|
|
390
|
+
>>> import numpy as np
|
|
391
|
+
>>> import mindspore.dataset as ds
|
|
392
|
+
>>> from mindspore import nn
|
|
393
|
+
>>> from mindspore.train import Model, ModelCheckpoint
|
|
394
|
+
>>>
|
|
395
|
+
>>> data = {"x": np.float32(np.random.rand(64, 10)), "y": np.random.randint(0, 5, (64,))}
|
|
396
|
+
>>> train_dataset = ds.NumpySlicesDataset(data=data).batch(32)
|
|
397
|
+
>>> net = nn.Dense(10, 5)
|
|
398
|
+
>>> crit = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction='mean')
|
|
399
|
+
>>> opt = nn.Momentum(net.trainable_params(), 0.01, 0.9)
|
|
400
|
+
>>> ckpt_callback = ModelCheckpoint(prefix="myckpt")
|
|
401
|
+
>>> model = Model(network=net, optimizer=opt, loss_fn=crit)
|
|
402
|
+
>>> model.train(2, train_dataset, callbacks=[ckpt_callback])
|
|
390
403
|
"""
|
|
391
404
|
|
|
392
405
|
def __init__(self, prefix='CKP', directory=None, config=None):
|
|
@@ -528,7 +541,9 @@ class ModelCheckpoint(Callback):
|
|
|
528
541
|
self._last_time_for_keep = time.time()
|
|
529
542
|
self._last_triggered_step = cb_params.cur_step_num
|
|
530
543
|
|
|
531
|
-
|
|
544
|
+
# TODO(MS_DISABLE_REF_MODE): Delete when remove MS_DISABLE_REF_MODE env.
|
|
545
|
+
if context.get_context("enable_ge") and os.getenv('MS_DISABLE_REF_MODE') \
|
|
546
|
+
and context.get_context("mode") == context.GRAPH_MODE:
|
|
532
547
|
set_cur_net(cb_params.train_network)
|
|
533
548
|
cb_params.train_network.exec_checkpoint_graph()
|
|
534
549
|
if "epoch_num" in self._append_dict:
|
|
@@ -85,13 +85,13 @@ class EarlyStopping(Callback):
|
|
|
85
85
|
>>> from mindspore import nn
|
|
86
86
|
>>> from mindspore.train import Model, EarlyStopping
|
|
87
87
|
>>> # Define the network structure of LeNet5. Refer to
|
|
88
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
88
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
89
89
|
>>> net = LeNet5()
|
|
90
90
|
>>> loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction='mean')
|
|
91
91
|
>>> optim = nn.Momentum(net.trainable_params(), 0.01, 0.9)
|
|
92
92
|
>>> model = Model(net, loss_fn=loss, optimizer=optim, metrics={"acc"})
|
|
93
93
|
>>> # Create the dataset taking MNIST as an example. Refer to
|
|
94
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
94
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
95
95
|
>>> dataset = create_dataset()
|
|
96
96
|
>>> cb = EarlyStopping(monitor="acc", patience=3, verbose=True)
|
|
97
97
|
>>> model.fit(10, dataset, callbacks=cb)
|
|
@@ -187,10 +187,10 @@ class SummaryLandscape:
|
|
|
187
187
|
... # If the device_target is Ascend, set the device_target to "Ascend"
|
|
188
188
|
... ms.set_context(mode=ms.GRAPH_MODE, device_target="GPU")
|
|
189
189
|
... # Create the dataset taking MNIST as an example. Refer to
|
|
190
|
-
... # https://gitee.com/mindspore/docs/blob/r2.
|
|
190
|
+
... # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
191
191
|
... ds_train = create_dataset()
|
|
192
192
|
... # Define the network structure of LeNet5. Refer to
|
|
193
|
-
... # https://gitee.com/mindspore/docs/blob/r2.
|
|
193
|
+
... # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
194
194
|
... network = LeNet5()
|
|
195
195
|
... net_loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction="mean")
|
|
196
196
|
... net_opt = nn.Momentum(network.trainable_params(), 0.01, 0.9)
|
|
@@ -210,13 +210,13 @@ class SummaryLandscape:
|
|
|
210
210
|
... # Simple usage for visualization landscape:
|
|
211
211
|
... def callback_fn():
|
|
212
212
|
... # Define the network structure of LeNet5. Refer to
|
|
213
|
-
... # https://gitee.com/mindspore/docs/blob/r2.
|
|
213
|
+
... # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
214
214
|
... network = LeNet5()
|
|
215
215
|
... net_loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction="mean")
|
|
216
216
|
... metrics = {"Loss": Loss()}
|
|
217
217
|
... model = Model(network, net_loss, metrics=metrics)
|
|
218
218
|
... # Create the dataset taking MNIST as an example. Refer to
|
|
219
|
-
... # https://gitee.com/mindspore/docs/blob/r2.
|
|
219
|
+
... # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
220
220
|
... ds_eval = create_dataset()
|
|
221
221
|
... return model, network, ds_eval, metrics
|
|
222
222
|
...
|
|
@@ -43,13 +43,13 @@ class LossMonitor(Callback):
|
|
|
43
43
|
>>> from mindspore.train import Model, LossMonitor
|
|
44
44
|
>>>
|
|
45
45
|
>>> # Define the network structure of LeNet5. Refer to
|
|
46
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
46
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
47
47
|
>>> net = LeNet5()
|
|
48
48
|
>>> loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction='mean')
|
|
49
49
|
>>> optim = nn.Momentum(net.trainable_params(), 0.01, 0.9)
|
|
50
50
|
>>> model = Model(net, loss_fn=loss, optimizer=optim)
|
|
51
51
|
>>> # Create the dataset taking MNIST as an example. Refer to
|
|
52
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
52
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
53
53
|
>>> dataset = create_dataset()
|
|
54
54
|
>>> loss_monitor = LossMonitor()
|
|
55
55
|
>>> model.train(10, dataset, callbacks=loss_monitor)
|
|
@@ -55,13 +55,13 @@ class OnRequestExit(Callback):
|
|
|
55
55
|
>>> import mindspore as ms
|
|
56
56
|
>>>
|
|
57
57
|
>>> # Define the network structure of LeNet5. Refer to
|
|
58
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
58
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
59
59
|
>>> net = LeNet5()
|
|
60
60
|
>>> loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction='mean')
|
|
61
61
|
>>> optim = nn.Momentum(net.trainable_params(), 0.01, 0.9)
|
|
62
62
|
>>> model = Model(net, loss_fn=loss, optimizer=optim)
|
|
63
63
|
>>> # Create the dataset taking MNIST as an example. Refer to
|
|
64
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
64
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
65
65
|
>>> dataset = create_dataset()
|
|
66
66
|
>>> on_request_exit = ms.train.OnRequestExit(file_name='LeNet5')
|
|
67
67
|
>>> model.train(10, dataset, callbacks=on_request_exit)
|
|
@@ -54,7 +54,6 @@ class ReduceLROnPlateau(Callback):
|
|
|
54
54
|
otherwise the valid monitor is ``"loss"``.
|
|
55
55
|
When `monitor` is ``"loss"``, if train network has multiple outputs,
|
|
56
56
|
the first element will be returned as training loss. Default: ``'eval_loss'``.
|
|
57
|
-
|
|
58
57
|
factor (float): factor by which the learning rate will be reduced.
|
|
59
58
|
`new_lr = lr * factor`. Default: ``0.1`` .
|
|
60
59
|
patience (int): `monitor` value is better than history best value over
|
|
@@ -77,7 +76,7 @@ class ReduceLROnPlateau(Callback):
|
|
|
77
76
|
min_lr (float): lower bound on the learning rate. Default: ``0`` .
|
|
78
77
|
|
|
79
78
|
Raises:
|
|
80
|
-
ValueError: `mode` not in 'auto'
|
|
79
|
+
ValueError: `mode` not in ``'auto'``, ``'min'`` or ``'max'``.
|
|
81
80
|
ValueError: The monitor value is not a scalar.
|
|
82
81
|
ValueError: The learning rate is not a Parameter.
|
|
83
82
|
|
|
@@ -85,13 +84,13 @@ class ReduceLROnPlateau(Callback):
|
|
|
85
84
|
>>> from mindspore import nn
|
|
86
85
|
>>> from mindspore.train import Model, ReduceLROnPlateau
|
|
87
86
|
>>> # Define the network structure of LeNet5. Refer to
|
|
88
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
87
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
89
88
|
>>> net = LeNet5()
|
|
90
89
|
>>> loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction='mean')
|
|
91
90
|
>>> optim = nn.Momentum(net.trainable_params(), 0.01, 0.9)
|
|
92
91
|
>>> model = Model(net, loss_fn=loss, optimizer=optim, metrics={"acc"})
|
|
93
92
|
>>> # Create the dataset taking MNIST as an example. Refer to
|
|
94
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
93
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
95
94
|
>>> dataset = create_dataset()
|
|
96
95
|
>>> cb = ReduceLROnPlateau(monitor="acc", patience=3, verbose=True)
|
|
97
96
|
>>> model.fit(10, dataset, callbacks=cb)
|
|
@@ -71,9 +71,9 @@ class LineageMetadata:
|
|
|
71
71
|
|
|
72
72
|
class SummaryCollector(Callback):
|
|
73
73
|
"""
|
|
74
|
-
SummaryCollector can help you to collect some common information
|
|
74
|
+
SummaryCollector can help you to collect some common information,
|
|
75
|
+
such as loss, learning late, computational graph and so on.
|
|
75
76
|
|
|
76
|
-
It can help you to collect loss, learning late, computational graph and so on.
|
|
77
77
|
SummaryCollector also enables the summary operator to collect data to summary files.
|
|
78
78
|
|
|
79
79
|
Note:
|
|
@@ -92,6 +92,8 @@ class SummaryCollector(Callback):
|
|
|
92
92
|
when (current steps % freq) equals to 0, and the first step will be collected at any time.
|
|
93
93
|
It is important to note that if the data sink mode is used, the unit will become the `epoch`.
|
|
94
94
|
It is not recommended to collect data too frequently, which can affect performance. Default: ``10`` .
|
|
95
|
+
num_process (int): Number of processes saving summary data. The more processes there are, the better the
|
|
96
|
+
performance, but there may be host memory overflow issues. Default: ``32`` .
|
|
95
97
|
collect_specified_data (Union[None, dict]): Perform custom operations on the collected data.
|
|
96
98
|
By default, if set to None, all data is collected as the default behavior.
|
|
97
99
|
You can customize the collected data with a dictionary.
|
|
@@ -104,10 +106,12 @@ class SummaryCollector(Callback):
|
|
|
104
106
|
training computational graph is collected. Default: ``True`` .
|
|
105
107
|
- collect_train_lineage (bool): Whether to collect lineage data for the training phase,
|
|
106
108
|
this field will be displayed on the `lineage page \
|
|
107
|
-
<https://www.mindspore.cn/mindinsight/docs/en/r2.
|
|
109
|
+
<https://www.mindspore.cn/mindinsight/docs/en/r2.2/lineage_and_scalars_comparison.html>`_
|
|
108
110
|
of MindInsight. Default: ``True`` .
|
|
109
111
|
- collect_eval_lineage (bool): Whether to collect lineage data for the evaluation phase,
|
|
110
|
-
this field will be displayed on the lineage page
|
|
112
|
+
this field will be displayed on the `lineage page
|
|
113
|
+
<https://www.mindspore.cn/mindinsight/docs/en/r2.2/lineage_and_scalars_comparison.html>`_
|
|
114
|
+
of MindInsight. Default: ``True`` .
|
|
111
115
|
- collect_input_data (bool): Whether to collect dataset for each training.
|
|
112
116
|
Currently only image data is supported.
|
|
113
117
|
If there are multiple columns of data in the dataset, the first column should be image data.
|
|
@@ -147,7 +151,8 @@ class SummaryCollector(Callback):
|
|
|
147
151
|
False: it means that after specified data is set, only the specified data is collected,
|
|
148
152
|
and the others are not collected. Default: ``True`` .
|
|
149
153
|
custom_lineage_data (Union[dict, None]): Allows you to customize the data and present it on the MingInsight
|
|
150
|
-
lineage page.
|
|
154
|
+
`lineage page <https://www.mindspore.cn/mindinsight/docs/en/r2.2/lineage_and_scalars_comparison.html>`_ .
|
|
155
|
+
In the custom data, the type of the key supports str, and the type of value supports str, int
|
|
151
156
|
and float. Default: ``None`` , it means there is no custom data.
|
|
152
157
|
collect_tensor_freq (Optional[int]): The same semantics as the `collect_freq`, but controls TensorSummary only.
|
|
153
158
|
Because TensorSummary data is too large to be compared with other summary data, this parameter is used to
|
|
@@ -186,10 +191,10 @@ class SummaryCollector(Callback):
|
|
|
186
191
|
... ms.set_context(mode=ms.GRAPH_MODE, device_target="Ascend")
|
|
187
192
|
... mnist_dataset_dir = '/path/to/mnist_dataset_directory'
|
|
188
193
|
... # Create the dataset taking MNIST as an example. Refer to
|
|
189
|
-
... # https://gitee.com/mindspore/docs/blob/r2.
|
|
194
|
+
... # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
190
195
|
... ds_train = create_dataset()
|
|
191
196
|
... # Define the network structure of LeNet5. Refer to
|
|
192
|
-
... # https://gitee.com/mindspore/docs/blob/r2.
|
|
197
|
+
... # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
193
198
|
... network = LeNet5(10)
|
|
194
199
|
... net_loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction="mean")
|
|
195
200
|
... net_opt = nn.Momentum(network.trainable_params(), 0.01, 0.9)
|
|
@@ -225,6 +230,7 @@ class SummaryCollector(Callback):
|
|
|
225
230
|
def __init__(self,
|
|
226
231
|
summary_dir,
|
|
227
232
|
collect_freq=10,
|
|
233
|
+
num_process=32,
|
|
228
234
|
collect_specified_data=None,
|
|
229
235
|
keep_default_action=True,
|
|
230
236
|
custom_lineage_data=None,
|
|
@@ -278,6 +284,7 @@ class SummaryCollector(Callback):
|
|
|
278
284
|
self._is_parse_loss_success = True
|
|
279
285
|
self._first_step = True
|
|
280
286
|
self._dataset_sink_mode = True
|
|
287
|
+
self._num_process = num_process
|
|
281
288
|
|
|
282
289
|
def __enter__(self):
|
|
283
290
|
self._record = SummaryRecord(log_dir=self._summary_dir,
|
|
@@ -1150,7 +1157,7 @@ class SummaryCollector(Callback):
|
|
|
1150
1157
|
except TypeError as exc:
|
|
1151
1158
|
logger.warning("Summary cannot collect the type of metrics, currently support type: dict, list, tuple, "
|
|
1152
1159
|
"str, int, float, bool and None. %s.", str(exc))
|
|
1153
|
-
self._parse_dataset(cb_params, eval_lineage)
|
|
1160
|
+
_ = self._parse_dataset(cb_params, eval_lineage)
|
|
1154
1161
|
|
|
1155
1162
|
eval_lineage_message = self._package_eval_lineage_message(eval_lineage)
|
|
1156
1163
|
self._record.add_value(PluginEnum.EVAL_LINEAGE.value, 'eval_lineage', eval_lineage_message)
|
|
@@ -30,30 +30,63 @@ class TimeMonitor(Callback):
|
|
|
30
30
|
if the program get `batch_num` during training, `data_size` will be set to `batch_num`,
|
|
31
31
|
otherwise `data_size` will be used. Default: ``None`` .
|
|
32
32
|
|
|
33
|
+
data_time (bool): Whether to sow the average time of fetching data in Host.
|
|
34
|
+
Note that data fetch and network compute are processed sequentially in non dataset sink mode, while
|
|
35
|
+
they are asynchronous in dataset sink mode. Default: ``False`` .
|
|
36
|
+
|
|
33
37
|
Raises:
|
|
34
38
|
ValueError: If data_size is not positive int.
|
|
39
|
+
TypeError: If data_time is not bool.
|
|
35
40
|
|
|
36
41
|
Examples:
|
|
37
42
|
>>> from mindspore import nn
|
|
38
43
|
>>> from mindspore.train import Model, TimeMonitor
|
|
39
44
|
>>>
|
|
40
45
|
>>> # Define the network structure of LeNet5. Refer to
|
|
41
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
46
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/lenet.py
|
|
42
47
|
>>> net = LeNet5()
|
|
43
48
|
>>> loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction='mean')
|
|
44
49
|
>>> optim = nn.Momentum(net.trainable_params(), 0.01, 0.9)
|
|
45
50
|
>>> model = Model(net, loss_fn=loss, optimizer=optim)
|
|
46
51
|
>>> # Create the dataset taking MNIST as an example. Refer to
|
|
47
|
-
>>> # https://gitee.com/mindspore/docs/blob/r2.
|
|
52
|
+
>>> # https://gitee.com/mindspore/docs/blob/r2.2/docs/mindspore/code/mnist.py
|
|
48
53
|
>>> dataset = create_dataset()
|
|
49
54
|
>>> time_monitor = TimeMonitor()
|
|
50
55
|
>>> model.train(10, dataset, callbacks=time_monitor)
|
|
51
56
|
"""
|
|
52
57
|
|
|
53
|
-
def __init__(self, data_size=None):
|
|
58
|
+
def __init__(self, data_size=None, data_time=False):
|
|
54
59
|
super(TimeMonitor, self).__init__()
|
|
55
60
|
self.data_size = data_size
|
|
56
61
|
self.epoch_time = time.time()
|
|
62
|
+
self.data_time = data_time
|
|
63
|
+
self.data_time_sum = 0.0
|
|
64
|
+
self.data_time_start = 0.0
|
|
65
|
+
self.data_sink = lambda c: c.original_args()["dataset_sink_mode"]
|
|
66
|
+
Validator.check_bool(data_time, "data_time")
|
|
67
|
+
|
|
68
|
+
def on_train_step_begin(self, run_context):
|
|
69
|
+
"""
|
|
70
|
+
Record time at the beginning of step.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
run_context (RunContext): Context of the process running. For more details,
|
|
74
|
+
please refer to :class:`mindspore.train.RunContext`.
|
|
75
|
+
"""
|
|
76
|
+
if self.data_time and not self.data_sink(run_context):
|
|
77
|
+
interval = time.time() - self.data_time_start
|
|
78
|
+
self.data_time_sum = self.data_time_sum + interval
|
|
79
|
+
|
|
80
|
+
def on_train_step_end(self, run_context):
|
|
81
|
+
"""
|
|
82
|
+
Record time at the end of step.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
run_context (RunContext): Context of the process running. For more details,
|
|
86
|
+
please refer to :class:`mindspore.train.RunContext`.
|
|
87
|
+
"""
|
|
88
|
+
if self.data_time and not self.data_sink(run_context):
|
|
89
|
+
self.data_time_start = time.time()
|
|
57
90
|
|
|
58
91
|
def epoch_begin(self, run_context):
|
|
59
92
|
"""
|
|
@@ -64,6 +97,9 @@ class TimeMonitor(Callback):
|
|
|
64
97
|
please refer to :class:`mindspore.train.RunContext`.
|
|
65
98
|
"""
|
|
66
99
|
self.epoch_time = time.time()
|
|
100
|
+
if self.data_time and not self.data_sink(run_context):
|
|
101
|
+
self.data_time_sum = 0.0
|
|
102
|
+
self.data_time_start = time.time()
|
|
67
103
|
|
|
68
104
|
def epoch_end(self, run_context):
|
|
69
105
|
"""
|
|
@@ -84,5 +120,22 @@ class TimeMonitor(Callback):
|
|
|
84
120
|
Validator.check_positive_int(step_size)
|
|
85
121
|
|
|
86
122
|
step_seconds = epoch_seconds / step_size
|
|
87
|
-
|
|
88
|
-
|
|
123
|
+
|
|
124
|
+
train_log = "{} epoch time: {:5.3f} ms, per step time: {:5.3f} ms".format(
|
|
125
|
+
mode.title(), epoch_seconds, step_seconds)
|
|
126
|
+
|
|
127
|
+
if self.data_time and not self.data_sink(run_context):
|
|
128
|
+
data_step_seconds = self.data_time_sum * 1000 / step_size
|
|
129
|
+
data_log = " (data time: {:5.3f} ms)".format(data_step_seconds)
|
|
130
|
+
train_log += data_log
|
|
131
|
+
elif self.data_time and self.data_sink(run_context):
|
|
132
|
+
# send info viewer to query epoch message of cur_epoch_num
|
|
133
|
+
send_info = cb_params["dataset_helper"].get_send_info(run_context)
|
|
134
|
+
epoch = cb_params["cur_epoch_num"]
|
|
135
|
+
epoch_send_info = send_info.epoch(epoch)
|
|
136
|
+
# show average time of fetching data time
|
|
137
|
+
fetch_data_time = epoch_send_info["fetch_data_time"]
|
|
138
|
+
data_log = " (data time: {:5.3f} ms)".format(fetch_data_time)
|
|
139
|
+
train_log += data_log
|
|
140
|
+
|
|
141
|
+
print(train_log, flush=True)
|
mindspore/train/data_sink.py
CHANGED
|
@@ -130,16 +130,10 @@ def data_sink(fn, dataset, sink_size=1, jit_config=None, input_signature=None):
|
|
|
130
130
|
A wrapper function to generate a function for the input function.
|
|
131
131
|
|
|
132
132
|
Note:
|
|
133
|
-
When using data sinking, the dataset will automatically
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
total_step = epochs * dataset_size
|
|
139
|
-
|
|
140
|
-
train_sink_step = total_step / sink_size
|
|
141
|
-
|
|
142
|
-
After transforming from `mindspore.data_sink`, you need to execute `train_sink_step` step for training.
|
|
133
|
+
When using data sinking, the dataset will be automatically sent in a loop, and only the step size of sinking
|
|
134
|
+
`sink_size` needs to be considered. The default value of `sink_size` is ``1``, which means that all data will
|
|
135
|
+
be sunk every epoch. If `sink_size` is greater than 1, the amount of data sunk per epoch will be the dataset
|
|
136
|
+
with a size of `sink_size`.
|
|
143
137
|
|
|
144
138
|
Args:
|
|
145
139
|
fn (Function): The Python function that will be run with dataset.
|
|
@@ -212,7 +206,7 @@ def data_sink(fn, dataset, sink_size=1, jit_config=None, input_signature=None):
|
|
|
212
206
|
real_sink_fun = _get_sink_fun(sink_fun, key_info, is_info_queue, dataset, jit_config)
|
|
213
207
|
|
|
214
208
|
loop = sink_size
|
|
215
|
-
if jit_config is not None:
|
|
209
|
+
if jit_config is not None and context.get_context('mode') == context.GRAPH_MODE:
|
|
216
210
|
loop = 1
|
|
217
211
|
|
|
218
212
|
out = None
|