mindspore 2.6.0rc1__cp311-cp311-win_amd64.whl → 2.7.0__cp311-cp311-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/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +2 -2
- mindspore/_c_dataengine.cp311-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp311-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp311-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +42 -11
- mindspore/_extends/builtin_operations.py +3 -3
- mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
- mindspore/_extends/optimize/cell_utils.py +96 -0
- mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
- mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
- mindspore/_extends/parse/__init__.py +3 -3
- mindspore/_extends/parse/compile_config.py +44 -22
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -2
- mindspore/_extends/parse/parser.py +65 -84
- mindspore/_extends/parse/resources.py +39 -0
- mindspore/_extends/parse/standard_method.py +58 -14
- mindspore/_extends/parse/trope.py +8 -1
- mindspore/_extends/pijit/__init__.py +1 -2
- mindspore/_extends/pijit/pijit_func_white_list.py +2 -5
- mindspore/amp.py +4 -22
- mindspore/atlprov.dll +0 -0
- mindspore/avcodec-59.dll +0 -0
- mindspore/avdevice-59.dll +0 -0
- mindspore/avfilter-8.dll +0 -0
- mindspore/avformat-59.dll +0 -0
- mindspore/avutil-57.dll +0 -0
- mindspore/boost/adasum.py +1 -1
- mindspore/boost/boost_cell_wrapper.py +4 -4
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/common/__init__.py +43 -12
- mindspore/common/_grad_function.py +2 -1
- mindspore/common/_pijit_context.py +28 -7
- mindspore/common/_stub_tensor.py +1 -209
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +178 -53
- mindspore/common/_utils.py +9 -1
- mindspore/common/api.py +377 -203
- mindspore/common/dtype.py +108 -57
- mindspore/common/dump.py +11 -16
- mindspore/common/dynamic_shape/__init__.py +0 -0
- mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +17 -23
- mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
- mindspore/common/file_system.py +59 -9
- mindspore/common/generator.py +5 -3
- mindspore/common/hook_handle.py +33 -5
- mindspore/common/jit_config.py +1 -1
- mindspore/common/jit_trace.py +84 -105
- mindspore/common/np_dtype.py +3 -3
- mindspore/common/parameter.py +27 -29
- mindspore/common/recompute.py +5 -7
- mindspore/common/sparse_tensor.py +0 -3
- mindspore/common/symbol.py +0 -1
- mindspore/common/tensor.py +117 -131
- mindspore/communication/_comm_helper.py +46 -4
- mindspore/communication/management.py +79 -7
- mindspore/context.py +67 -55
- mindspore/dataset/__init__.py +1 -1
- mindspore/dataset/audio/transforms.py +1 -1
- mindspore/dataset/core/config.py +38 -4
- mindspore/dataset/engine/datasets.py +350 -322
- mindspore/dataset/engine/datasets_user_defined.py +70 -24
- mindspore/dataset/engine/iterators.py +2 -2
- mindspore/dataset/engine/obs/config_loader.py +2 -2
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
- mindspore/dataset/transforms/c_transforms.py +2 -2
- mindspore/dataset/transforms/py_transforms.py +7 -3
- mindspore/dataset/transforms/transforms.py +10 -6
- mindspore/dataset/vision/__init__.py +1 -1
- mindspore/dataset/vision/py_transforms.py +8 -8
- mindspore/dataset/vision/transforms.py +17 -5
- mindspore/dataset/vision/utils.py +632 -21
- mindspore/dataset/vision/validators.py +1 -0
- mindspore/device_context/ascend/device.py +1 -1
- mindspore/device_context/ascend/op_tuning.py +35 -1
- mindspore/device_context/gpu/__init__.py +2 -2
- mindspore/device_context/gpu/device.py +1 -1
- mindspore/device_context/gpu/op_precision.py +4 -2
- mindspore/device_context/gpu/op_tuning.py +6 -3
- mindspore/device_manager.py +16 -9
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +3 -4
- mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
- mindspore/experimental/optim/adadelta.py +13 -20
- mindspore/experimental/optim/adagrad.py +15 -22
- mindspore/experimental/optim/adam.py +17 -24
- mindspore/experimental/optim/adamax.py +14 -22
- mindspore/experimental/optim/adamw.py +28 -34
- mindspore/experimental/optim/asgd.py +15 -25
- mindspore/experimental/optim/lr_scheduler.py +27 -45
- mindspore/experimental/optim/nadam.py +14 -24
- mindspore/experimental/optim/optimizer.py +13 -23
- mindspore/experimental/optim/radam.py +18 -24
- mindspore/experimental/optim/rmsprop.py +14 -25
- mindspore/experimental/optim/rprop.py +15 -26
- mindspore/experimental/optim/sgd.py +9 -19
- mindspore/hal/__init__.py +4 -4
- mindspore/hal/contiguous_tensors_handle.py +2 -2
- mindspore/hal/memory.py +27 -7
- mindspore/include/api/cell.h +65 -5
- mindspore/include/api/cfg.h +24 -7
- mindspore/include/api/context.h +1 -0
- mindspore/include/api/delegate.h +10 -2
- mindspore/include/api/dual_abi_helper.h +100 -19
- mindspore/include/api/graph.h +14 -1
- mindspore/include/api/kernel.h +16 -3
- mindspore/include/api/kernel_api.h +9 -1
- mindspore/include/api/metrics/accuracy.h +9 -0
- mindspore/include/api/model.h +8 -1
- mindspore/include/api/model_group.h +4 -0
- mindspore/include/api/model_parallel_runner.h +2 -0
- mindspore/include/api/status.h +48 -10
- mindspore/include/api/types.h +8 -3
- mindspore/include/c_api/model_c.h +0 -58
- mindspore/include/c_api/tensor_c.h +0 -26
- mindspore/include/dataset/constants.h +9 -0
- mindspore/include/dataset/vision_ascend.h +1 -1
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/cifar10.py +61 -11
- mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
- mindspore/mindspore_backend_common.dll +0 -0
- mindspore/mindspore_backend_manager.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_cpu_res_manager.dll +0 -0
- mindspore/mindspore_dump.dll +0 -0
- mindspore/mindspore_frontend.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_memory_pool.dll +0 -0
- mindspore/mindspore_ms_backend.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mindspore_ops_host.dll +0 -0
- mindspore/mindspore_ops_kernel_common.dll +0 -0
- mindspore/mindspore_profiler.dll +0 -0
- mindspore/mindspore_pyboost.dll +0 -0
- mindspore/mindspore_pynative.dll +0 -0
- mindspore/mindspore_res_manager.dll +0 -0
- mindspore/mindspore_runtime_pipeline.dll +0 -0
- mindspore/mint/__init__.py +6 -46
- mindspore/mint/distributed/__init__.py +5 -0
- mindspore/mint/distributed/distributed.py +429 -23
- mindspore/mint/nn/__init__.py +1 -1
- mindspore/mint/nn/functional.py +53 -6
- mindspore/mint/nn/layer/_functions.py +163 -294
- mindspore/mint/nn/layer/activation.py +8 -6
- mindspore/mint/nn/layer/conv.py +140 -104
- mindspore/mint/nn/layer/normalization.py +11 -25
- mindspore/mint/optim/adam.py +19 -18
- mindspore/mint/optim/adamw.py +14 -8
- mindspore/mint/optim/sgd.py +5 -5
- mindspore/msobj140.dll +0 -0
- mindspore/mspdb140.dll +0 -0
- mindspore/mspdbcore.dll +0 -0
- mindspore/mspdbst.dll +0 -0
- mindspore/mspft140.dll +0 -0
- mindspore/msvcdis140.dll +0 -0
- mindspore/msvcp140_1.dll +0 -0
- mindspore/msvcp140_2.dll +0 -0
- mindspore/msvcp140_atomic_wait.dll +0 -0
- mindspore/msvcp140_codecvt_ids.dll +0 -0
- mindspore/nn/cell.py +491 -623
- mindspore/nn/grad/cell_grad.py +11 -12
- mindspore/nn/layer/activation.py +36 -36
- mindspore/nn/layer/basic.py +74 -77
- mindspore/nn/layer/channel_shuffle.py +4 -4
- mindspore/nn/layer/combined.py +4 -2
- mindspore/nn/layer/conv.py +117 -110
- mindspore/nn/layer/dense.py +9 -7
- mindspore/nn/layer/embedding.py +50 -52
- mindspore/nn/layer/image.py +38 -40
- mindspore/nn/layer/math.py +111 -112
- mindspore/nn/layer/normalization.py +56 -44
- mindspore/nn/layer/pooling.py +58 -63
- mindspore/nn/layer/rnn_cells.py +33 -33
- mindspore/nn/layer/rnns.py +56 -56
- mindspore/nn/layer/thor_layer.py +74 -73
- mindspore/nn/layer/transformer.py +11 -1
- mindspore/nn/learning_rate_schedule.py +20 -20
- mindspore/nn/loss/loss.py +79 -81
- mindspore/nn/optim/adam.py +4 -6
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/asgd.py +2 -0
- mindspore/nn/optim/lamb.py +1 -3
- mindspore/nn/optim/optimizer.py +1 -1
- mindspore/nn/optim/tft_wrapper.py +2 -3
- mindspore/nn/optim/thor.py +2 -2
- mindspore/nn/probability/distribution/_utils/utils.py +2 -2
- mindspore/nn/probability/distribution/exponential.py +2 -1
- mindspore/nn/probability/distribution/poisson.py +2 -1
- mindspore/nn/sparse/sparse.py +3 -3
- mindspore/nn/wrap/cell_wrapper.py +73 -42
- mindspore/nn/wrap/grad_reducer.py +37 -52
- mindspore/nn/wrap/loss_scale.py +72 -74
- mindspore/numpy/array_creations.py +7 -7
- mindspore/numpy/fft.py +1 -1
- mindspore/numpy/math_ops.py +5 -5
- mindspore/numpy/utils_const.py +1 -1
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
- mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
- mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
- mindspore/ops/_op_impl/cpu/__init__.py +1 -0
- mindspore/{experimental/es/__init__.py → ops/_op_impl/cpu/joinedstr_op.py} +12 -6
- mindspore/ops/_vmap/vmap_array_ops.py +31 -13
- mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +54 -13
- mindspore/ops/auto_generate/gen_extend_func.py +27 -145
- mindspore/ops/auto_generate/gen_ops_def.py +1027 -347
- mindspore/ops/auto_generate/gen_ops_prim.py +2341 -1117
- mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
- mindspore/ops/composite/__init__.py +10 -0
- mindspore/ops/composite/base.py +9 -5
- mindspore/ops/composite/multitype_ops/__init__.py +12 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +133 -109
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
- mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
- mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
- mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
- mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
- mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
- mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
- mindspore/ops/function/__init__.py +4 -1
- mindspore/ops/function/_add_attr_func.py +11 -6
- mindspore/ops/function/array_func.py +19 -102
- mindspore/ops/function/debug_func.py +8 -5
- mindspore/ops/function/grad/grad_func.py +5 -13
- mindspore/ops/function/math_func.py +77 -572
- mindspore/ops/function/nn_func.py +46 -94
- mindspore/ops/function/other_func.py +4 -1
- mindspore/ops/function/random_func.py +44 -5
- mindspore/ops/function/vmap_func.py +2 -1
- mindspore/ops/functional.py +4 -4
- mindspore/ops/functional_overload.py +594 -18
- mindspore/ops/op_info_register.py +21 -0
- mindspore/ops/operations/__init__.py +16 -11
- mindspore/ops/operations/_custom_ops_utils.py +689 -34
- mindspore/ops/operations/_inner_ops.py +14 -18
- mindspore/ops/operations/_sequence_ops.py +1 -1
- mindspore/ops/operations/array_ops.py +5 -51
- mindspore/ops/operations/comm_ops.py +186 -41
- mindspore/ops/operations/custom_ops.py +303 -177
- mindspore/ops/operations/debug_ops.py +59 -4
- mindspore/ops/operations/image_ops.py +13 -13
- mindspore/ops/operations/manually_defined/ops_def.py +27 -28
- mindspore/ops/operations/math_ops.py +8 -9
- mindspore/ops/operations/nn_ops.py +8 -40
- mindspore/ops/primitive.py +9 -20
- mindspore/ops/tensor_method.py +63 -15
- mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
- mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
- mindspore/ops_generate/api/functions_cc_generator.py +58 -10
- mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
- mindspore/ops_generate/common/base_generator.py +14 -0
- mindspore/ops_generate/common/gen_constants.py +8 -3
- mindspore/ops_generate/common/gen_utils.py +0 -19
- mindspore/ops_generate/common/op_proto.py +11 -4
- mindspore/ops_generate/common/template.py +88 -11
- mindspore/ops_generate/gen_ops.py +1 -1
- mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
- mindspore/ops_generate/op_def/ops_def_cc_generator.py +0 -3
- mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
- mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
- mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
- mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
- mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
- mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -16
- mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
- mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
- mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
- mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
- mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
- mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
- mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
- mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
- mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
- mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
- mindspore/parallel/_auto_parallel_context.py +16 -23
- mindspore/parallel/_cell_wrapper.py +113 -45
- mindspore/parallel/_parallel_serialization.py +4 -3
- mindspore/parallel/_ps_context.py +4 -6
- mindspore/parallel/_tensor.py +167 -12
- mindspore/parallel/_transformer/moe.py +1 -1
- mindspore/parallel/_transformer/transformer.py +17 -12
- mindspore/parallel/_utils.py +5 -11
- mindspore/parallel/auto_parallel.py +35 -14
- mindspore/parallel/checkpoint_convert.py +3 -3
- mindspore/parallel/checkpoint_transform.py +13 -7
- mindspore/parallel/cluster/process_entity/_api.py +88 -49
- mindspore/parallel/cluster/process_entity/_utils.py +95 -7
- mindspore/parallel/cluster/run.py +48 -7
- mindspore/parallel/function/__init__.py +8 -1
- mindspore/parallel/function/reshard_func.py +12 -12
- mindspore/parallel/nn/__init__.py +15 -2
- mindspore/parallel/nn/parallel_cell_wrapper.py +50 -14
- mindspore/parallel/nn/parallel_grad_reducer.py +7 -14
- mindspore/parallel/shard.py +10 -25
- mindspore/parallel/transform_safetensors.py +469 -174
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/__init__.py +2 -1
- mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
- mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
- mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +12 -6
- mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
- mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
- mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
- mindspore/profiler/analysis/task_manager.py +1 -1
- mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
- mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +10 -9
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +43 -23
- mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
- mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
- mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
- mindspore/profiler/common/constant.py +16 -0
- mindspore/profiler/common/msprof_cmd_tool.py +2 -2
- mindspore/profiler/common/path_manager.py +9 -0
- mindspore/profiler/common/profiler_context.py +50 -29
- mindspore/profiler/common/profiler_info.py +0 -16
- mindspore/profiler/common/profiler_meta_data.py +1 -0
- mindspore/profiler/common/profiler_op_analyse.py +239 -0
- mindspore/profiler/common/profiler_output_path.py +23 -8
- mindspore/profiler/common/profiler_parameters.py +128 -35
- mindspore/profiler/dynamic_profile/__init__.py +0 -0
- mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
- mindspore/profiler/dynamic_profiler.py +374 -338
- mindspore/profiler/envprofiler.py +42 -12
- mindspore/profiler/experimental_config.py +112 -7
- mindspore/profiler/mstx.py +33 -12
- mindspore/profiler/platform/__init__.py +2 -3
- mindspore/profiler/platform/cpu_profiler.py +10 -4
- mindspore/profiler/platform/npu_profiler.py +30 -20
- mindspore/profiler/profiler.py +218 -154
- mindspore/profiler/profiler_action_controller.py +65 -77
- mindspore/profiler/profiler_interface.py +2 -2
- mindspore/profiler/schedule.py +10 -4
- mindspore/rewrite/common/config.py +1 -0
- mindspore/rewrite/common/namer.py +1 -0
- mindspore/rewrite/common/namespace.py +1 -0
- mindspore/rewrite/node/node.py +31 -11
- mindspore/rewrite/parsers/assign_parser.py +1 -1
- mindspore/rewrite/symbol_tree/symbol_tree.py +2 -2
- mindspore/run_check/_check_version.py +7 -10
- mindspore/runtime/__init__.py +8 -6
- mindspore/runtime/event.py +10 -4
- mindspore/runtime/executor.py +87 -45
- mindspore/runtime/memory.py +31 -32
- mindspore/runtime/thread_bind_core.py +299 -165
- mindspore/safeguard/rewrite_obfuscation.py +12 -13
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +17 -7
- mindspore/train/amp.py +43 -23
- mindspore/train/callback/__init__.py +5 -5
- mindspore/train/callback/_callback.py +2 -1
- mindspore/train/callback/_checkpoint.py +4 -14
- mindspore/train/callback/_flops_collector.py +11 -7
- mindspore/train/callback/_landscape.py +0 -1
- mindspore/train/callback/_train_fault_tolerance.py +98 -21
- mindspore/train/data_sink.py +15 -6
- mindspore/train/dataset_helper.py +14 -5
- mindspore/train/model.py +133 -69
- mindspore/train/serialization.py +168 -126
- mindspore/train/summary/summary_record.py +13 -2
- mindspore/train/train_thor/model_thor.py +2 -2
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +3 -2
- mindspore/utils/dryrun.py +0 -6
- mindspore/utils/runtime_execution_order_check.py +163 -77
- mindspore/utils/sdc_detect.py +68 -0
- mindspore/utils/utils.py +14 -17
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/METADATA +5 -4
- {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/RECORD +403 -442
- mindspore/_deprecated/jit.py +0 -198
- mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
- mindspore/communication/_hccl_management.py +0 -297
- mindspore/experimental/es/embedding_service.py +0 -891
- mindspore/experimental/es/embedding_service_layer.py +0 -581
- mindspore/profiler/common/validator/__init__.py +0 -14
- mindspore/profiler/common/validator/validate_path.py +0 -84
- mindspore/profiler/parser/__init__.py +0 -14
- mindspore/profiler/parser/aicpu_data_parser.py +0 -272
- mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
- mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
- mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
- mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
- mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
- mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
- mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
- mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
- mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
- mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
- mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
- mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
- mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
- mindspore/profiler/parser/ascend_flops_generator.py +0 -116
- mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
- mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
- mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
- mindspore/profiler/parser/ascend_memory_generator.py +0 -185
- mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
- mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
- mindspore/profiler/parser/ascend_op_generator.py +0 -334
- mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
- mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
- mindspore/profiler/parser/base_timeline_generator.py +0 -483
- mindspore/profiler/parser/container.py +0 -229
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
- mindspore/profiler/parser/flops_parser.py +0 -531
- mindspore/profiler/parser/framework_enum.py +0 -111
- mindspore/profiler/parser/framework_parser.py +0 -464
- mindspore/profiler/parser/framework_struct.py +0 -61
- mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
- mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
- mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
- mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
- mindspore/profiler/parser/hccl_parser.py +0 -573
- mindspore/profiler/parser/hwts_log_parser.py +0 -122
- mindspore/profiler/parser/integrator.py +0 -526
- mindspore/profiler/parser/memory_usage_parser.py +0 -277
- mindspore/profiler/parser/minddata_analyzer.py +0 -800
- mindspore/profiler/parser/minddata_parser.py +0 -186
- mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
- mindspore/profiler/parser/op_intermediate_parser.py +0 -149
- mindspore/profiler/parser/optime_parser.py +0 -250
- mindspore/profiler/parser/profiler_info.py +0 -213
- mindspore/profiler/parser/step_trace_parser.py +0 -666
- mindspore/utils/hooks.py +0 -81
- /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
- {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/WHEEL +0 -0
- {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/entry_points.txt +0 -0
- {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/top_level.txt +0 -0
mindspore/nn/layer/image.py
CHANGED
|
@@ -22,9 +22,7 @@ import numpy as np
|
|
|
22
22
|
import mindspore.common.dtype as mstype
|
|
23
23
|
import mindspore.ops as ops
|
|
24
24
|
from mindspore.common.tensor import Tensor
|
|
25
|
-
from mindspore.ops import operations as P
|
|
26
25
|
from mindspore.ops.operations import _inner_ops as inner
|
|
27
|
-
from mindspore.ops import functional as F
|
|
28
26
|
from mindspore.ops.primitive import constexpr, _primexpr
|
|
29
27
|
from mindspore import _checkparam as validator
|
|
30
28
|
from mindspore.nn.layer.conv import Conv2d
|
|
@@ -80,21 +78,21 @@ class ImageGradients(Cell):
|
|
|
80
78
|
super(ImageGradients, self).__init__()
|
|
81
79
|
|
|
82
80
|
def construct(self, images):
|
|
83
|
-
_check_input_4d(
|
|
84
|
-
batch_size, depth, height, width =
|
|
81
|
+
_check_input_4d(ops.shape(images), "images", self.cls_name)
|
|
82
|
+
batch_size, depth, height, width = ops.Shape()(images)
|
|
85
83
|
if height == 1:
|
|
86
|
-
dy =
|
|
84
|
+
dy = ops.fill(ops.DType()(images), (batch_size, depth, 1, width), 0)
|
|
87
85
|
else:
|
|
88
86
|
dy = images[:, :, 1:, :] - images[:, :, :height - 1, :]
|
|
89
|
-
dy_last =
|
|
90
|
-
dy =
|
|
87
|
+
dy_last = ops.fill(ops.DType()(images), (batch_size, depth, 1, width), 0)
|
|
88
|
+
dy = ops.Concat(2)((dy, dy_last))
|
|
91
89
|
|
|
92
90
|
if width == 1:
|
|
93
|
-
dx =
|
|
91
|
+
dx = ops.fill(ops.DType()(images), (batch_size, depth, height, 1), 0)
|
|
94
92
|
else:
|
|
95
93
|
dx = images[:, :, :, 1:] - images[:, :, :, :width - 1]
|
|
96
|
-
dx_last =
|
|
97
|
-
dx =
|
|
94
|
+
dx_last = ops.fill(ops.DType()(images), (batch_size, depth, height, 1), 0)
|
|
95
|
+
dx = ops.Concat(3)((dx, dx_last))
|
|
98
96
|
return dy, dx
|
|
99
97
|
|
|
100
98
|
|
|
@@ -102,8 +100,8 @@ def _convert_img_dtype_to_float32(img, max_val):
|
|
|
102
100
|
"""convert img dtype to float32"""
|
|
103
101
|
# Usually max_val is 1.0 or 255, we will do the scaling if max_val > 1.
|
|
104
102
|
# We will scale img pixel value if max_val > 1. and just cast otherwise.
|
|
105
|
-
ret =
|
|
106
|
-
max_val =
|
|
103
|
+
ret = ops.cast(img, mstype.float32)
|
|
104
|
+
max_val = ops.scalar_cast(max_val, mstype.float32)
|
|
107
105
|
if max_val > 1.:
|
|
108
106
|
scale = 1. / max_val
|
|
109
107
|
ret = ret * scale
|
|
@@ -113,7 +111,7 @@ def _convert_img_dtype_to_float32(img, max_val):
|
|
|
113
111
|
@constexpr
|
|
114
112
|
def _get_dtype_max(dtype):
|
|
115
113
|
"""get max of the dtype"""
|
|
116
|
-
np_type = mstype.
|
|
114
|
+
np_type = mstype._dtype_to_nptype(dtype) # pylint:disable=protected-access
|
|
117
115
|
if issubclass(np_type, numbers.Integral):
|
|
118
116
|
dtype_max = np.float64(np.iinfo(np_type).max).item()
|
|
119
117
|
else:
|
|
@@ -157,8 +155,8 @@ def _create_window(size, sigma):
|
|
|
157
155
|
|
|
158
156
|
|
|
159
157
|
def _split_img(x):
|
|
160
|
-
_, c, _, _ =
|
|
161
|
-
img_split =
|
|
158
|
+
_, c, _, _ = ops.shape(x)
|
|
159
|
+
img_split = ops.Split(1, c)
|
|
162
160
|
output = img_split(x)
|
|
163
161
|
return output, c
|
|
164
162
|
|
|
@@ -177,8 +175,8 @@ def _compute_per_channel_loss(c1, c2, img1, img2, conv):
|
|
|
177
175
|
sigma2_sq = sigma2_tmp - mu2_sq
|
|
178
176
|
sigma12_tmp = conv(dot_img)
|
|
179
177
|
sigma12 = sigma12_tmp - mu1_mu2
|
|
180
|
-
a =
|
|
181
|
-
b =
|
|
178
|
+
a = 2 * mu1_mu2 + c1
|
|
179
|
+
b = mu1_sq + mu2_sq + c1
|
|
182
180
|
v1 = 2 * sigma12 + c2
|
|
183
181
|
v2 = sigma1_sq + sigma2_sq + c2
|
|
184
182
|
ssim = (a * v1) / (b * v2)
|
|
@@ -209,7 +207,7 @@ class SSIM(Cell):
|
|
|
209
207
|
r"""
|
|
210
208
|
Returns SSIM index between two images.
|
|
211
209
|
|
|
212
|
-
Its implementation is based on Wang, Z., Bovik, A. C., Sheikh, H. R., & Simoncelli, E.
|
|
210
|
+
Its implementation is based on Wang, Z., Bovik, A. C., Sheikh, H. R., & Simoncelli, E. ops. (2004) `Image quality
|
|
213
211
|
assessment: from error visibility to structural similarity <https://ieeexplore.ieee.org/document/1284395>`_ .
|
|
214
212
|
|
|
215
213
|
SSIM is a measure of the similarity of two pictures.
|
|
@@ -275,14 +273,14 @@ class SSIM(Cell):
|
|
|
275
273
|
window = _create_window(filter_size, filter_sigma)
|
|
276
274
|
self.conv = _conv2d(1, 1, filter_size, Tensor(window))
|
|
277
275
|
self.conv.weight.requires_grad = False
|
|
278
|
-
self.reduce_mean =
|
|
279
|
-
self.concat =
|
|
276
|
+
self.reduce_mean = ops.ReduceMean()
|
|
277
|
+
self.concat = ops.Concat(axis=1)
|
|
280
278
|
|
|
281
279
|
def construct(self, img1, img2):
|
|
282
|
-
_check_input_dtype(
|
|
283
|
-
_check_input_filter_size(
|
|
280
|
+
_check_input_dtype(ops.dtype(img1), "img1", [mstype.float32, mstype.float16], self.cls_name)
|
|
281
|
+
_check_input_filter_size(ops.shape(img1), "img1", self.filter_size, self.cls_name)
|
|
284
282
|
inner.SameTypeShape()(img1, img2)
|
|
285
|
-
dtype_max_val = _get_dtype_max(
|
|
283
|
+
dtype_max_val = _get_dtype_max(ops.dtype(img1))
|
|
286
284
|
max_val = _convert_img_dtype_to_float32(self.max_val, dtype_max_val)
|
|
287
285
|
img1 = _convert_img_dtype_to_float32(img1, dtype_max_val)
|
|
288
286
|
img2 = _convert_img_dtype_to_float32(img2, dtype_max_val)
|
|
@@ -308,7 +306,7 @@ class MSSSIM(Cell):
|
|
|
308
306
|
|
|
309
307
|
Its implementation is based on `Multiscale structural similarity
|
|
310
308
|
for image quality assessment <https://ieeexplore.ieee.org/document/1292216>`_
|
|
311
|
-
by Zhou Wang, Eero
|
|
309
|
+
by Zhou Wang, Eero ops. Simoncelli, and Alan C. Bovik, published on Signals, Systems and Computers in 2004.
|
|
312
310
|
|
|
313
311
|
.. math::
|
|
314
312
|
|
|
@@ -377,19 +375,19 @@ class MSSSIM(Cell):
|
|
|
377
375
|
self.weight_tensor = Tensor(power_factors, mstype.float32)
|
|
378
376
|
self.avg_pool = AvgPool2d(kernel_size=2, stride=2, pad_mode='valid')
|
|
379
377
|
self.relu = ReLU()
|
|
380
|
-
self.reduce_mean =
|
|
381
|
-
self.prod =
|
|
382
|
-
self.pow =
|
|
383
|
-
self.stack =
|
|
384
|
-
self.concat =
|
|
378
|
+
self.reduce_mean = ops.ReduceMean()
|
|
379
|
+
self.prod = ops.ReduceProd()
|
|
380
|
+
self.pow = ops.Pow()
|
|
381
|
+
self.stack = ops.Stack(axis=-1)
|
|
382
|
+
self.concat = ops.Concat(axis=1)
|
|
385
383
|
|
|
386
384
|
def construct(self, img1, img2):
|
|
387
|
-
_check_input_4d(
|
|
388
|
-
_check_input_4d(
|
|
385
|
+
_check_input_4d(ops.shape(img1), "img1", self.cls_name)
|
|
386
|
+
_check_input_4d(ops.shape(img2), "img2", self.cls_name)
|
|
389
387
|
valid_type = [mstype.float64, mstype.float32, mstype.float16, mstype.uint8]
|
|
390
|
-
_check_input_dtype(
|
|
388
|
+
_check_input_dtype(ops.dtype(img1), 'img1', valid_type, self.cls_name)
|
|
391
389
|
inner.SameTypeShape()(img1, img2)
|
|
392
|
-
dtype_max_val = _get_dtype_max(
|
|
390
|
+
dtype_max_val = _get_dtype_max(ops.dtype(img1))
|
|
393
391
|
max_val = _convert_img_dtype_to_float32(self.max_val, dtype_max_val)
|
|
394
392
|
img1 = _convert_img_dtype_to_float32(img1, dtype_max_val)
|
|
395
393
|
img2 = _convert_img_dtype_to_float32(img2, dtype_max_val)
|
|
@@ -463,16 +461,16 @@ class PSNR(Cell):
|
|
|
463
461
|
self.max_val = max_val
|
|
464
462
|
|
|
465
463
|
def construct(self, img1, img2):
|
|
466
|
-
_check_input_4d(
|
|
467
|
-
_check_input_4d(
|
|
464
|
+
_check_input_4d(ops.shape(img1), "img1", self.cls_name)
|
|
465
|
+
_check_input_4d(ops.shape(img2), "img2", self.cls_name)
|
|
468
466
|
inner.SameTypeShape()(img1, img2)
|
|
469
|
-
dtype_max_val = _get_dtype_max(
|
|
467
|
+
dtype_max_val = _get_dtype_max(ops.dtype(img1))
|
|
470
468
|
max_val = _convert_img_dtype_to_float32(self.max_val, dtype_max_val)
|
|
471
469
|
img1 = _convert_img_dtype_to_float32(img1, dtype_max_val)
|
|
472
470
|
img2 = _convert_img_dtype_to_float32(img2, dtype_max_val)
|
|
473
471
|
|
|
474
|
-
mse =
|
|
475
|
-
psnr = 10 *
|
|
472
|
+
mse = ops.ReduceMean()(ops.square(img1 - img2), (-3, -2, -1))
|
|
473
|
+
psnr = 10 * ops.Log()(ops.square(max_val) / mse) / ops.scalar_log(10.0)
|
|
476
474
|
|
|
477
475
|
return psnr
|
|
478
476
|
|
|
@@ -545,10 +543,10 @@ class CentralCrop(Cell):
|
|
|
545
543
|
validator.check_value_type("central_fraction", central_fraction, [float], self.cls_name)
|
|
546
544
|
validator.check_float_range(central_fraction, 0.0, 1.0, validator.INC_RIGHT, 'central_fraction', self.cls_name)
|
|
547
545
|
self.central_fraction = central_fraction
|
|
548
|
-
self.slice =
|
|
546
|
+
self.slice = ops.Slice()
|
|
549
547
|
|
|
550
548
|
def construct(self, image):
|
|
551
|
-
image_shape =
|
|
549
|
+
image_shape = ops.shape(image)
|
|
552
550
|
rank = len(image_shape)
|
|
553
551
|
_check_rank(rank, image_shape, "image", self.cls_name)
|
|
554
552
|
if self.central_fraction == 1.0:
|
mindspore/nn/layer/math.py
CHANGED
|
@@ -18,11 +18,10 @@ from __future__ import absolute_import
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
|
|
20
20
|
from mindspore import log as logger
|
|
21
|
-
from mindspore
|
|
21
|
+
from mindspore import ops
|
|
22
22
|
from mindspore.common.tensor import Tensor
|
|
23
23
|
from mindspore.common._decorator import deprecated
|
|
24
24
|
from mindspore.ops.primitive import constexpr, _primexpr
|
|
25
|
-
from mindspore.ops import functional as F
|
|
26
25
|
from mindspore.nn.cell import Cell
|
|
27
26
|
from mindspore.common import dtype as mstype
|
|
28
27
|
from mindspore import _checkparam as validator
|
|
@@ -109,10 +108,10 @@ class ReduceLogSumExp(Cell):
|
|
|
109
108
|
validator.check_value_type('axis', axis, [int, list, tuple], self.cls_name)
|
|
110
109
|
validator.check_value_type('keep_dims', keep_dims, [bool], self.cls_name)
|
|
111
110
|
self.axis = axis
|
|
112
|
-
self.exp =
|
|
113
|
-
self.sum =
|
|
114
|
-
self.log =
|
|
115
|
-
self.max =
|
|
111
|
+
self.exp = ops.Exp()
|
|
112
|
+
self.sum = ops.ReduceSum(keep_dims)
|
|
113
|
+
self.log = ops.Log()
|
|
114
|
+
self.max = ops.ReduceMax()
|
|
116
115
|
|
|
117
116
|
def construct(self, x):
|
|
118
117
|
x_max = self.max(x)
|
|
@@ -218,28 +217,28 @@ class LGamma(Cell):
|
|
|
218
217
|
self.log_lanczos_gamma_plus_one_half = np.log(self.lanczos_gamma_plus_one_half)
|
|
219
218
|
|
|
220
219
|
# operations
|
|
221
|
-
self.log =
|
|
222
|
-
self.log1p =
|
|
223
|
-
self.abs =
|
|
224
|
-
self.shape =
|
|
225
|
-
self.dtype =
|
|
226
|
-
self.floor =
|
|
227
|
-
self.equal =
|
|
228
|
-
self.greater =
|
|
229
|
-
self.less =
|
|
230
|
-
self.lessequal =
|
|
231
|
-
self.select =
|
|
232
|
-
self.sin =
|
|
233
|
-
self.isfinite =
|
|
234
|
-
self.ones_like =
|
|
220
|
+
self.log = ops.Log()
|
|
221
|
+
self.log1p = ops.Log1p()
|
|
222
|
+
self.abs = ops.Abs()
|
|
223
|
+
self.shape = ops.Shape()
|
|
224
|
+
self.dtype = ops.DType()
|
|
225
|
+
self.floor = ops.Floor()
|
|
226
|
+
self.equal = ops.Equal()
|
|
227
|
+
self.greater = ops.Greater()
|
|
228
|
+
self.less = ops.Less()
|
|
229
|
+
self.lessequal = ops.LessEqual()
|
|
230
|
+
self.select = ops.Select()
|
|
231
|
+
self.sin = ops.Sin()
|
|
232
|
+
self.isfinite = ops.IsFinite()
|
|
233
|
+
self.ones_like = ops.OnesLike()
|
|
235
234
|
|
|
236
235
|
def construct(self, x):
|
|
237
236
|
input_dtype = self.dtype(x)
|
|
238
237
|
_check_input_dtype("x", input_dtype, [mstype.float16, mstype.float32], self.cls_name)
|
|
239
|
-
if
|
|
240
|
-
infinity = self.ones_like(x) *
|
|
238
|
+
if ops.is_sequence_value_unknown(self.shape(x)):
|
|
239
|
+
infinity = self.ones_like(x) * ops.cast(self.inf, input_dtype)
|
|
241
240
|
else:
|
|
242
|
-
infinity =
|
|
241
|
+
infinity = ops.fill(input_dtype, self.shape(x), self.inf)
|
|
243
242
|
|
|
244
243
|
need_to_reflect = self.less(x, 0.5)
|
|
245
244
|
neg_input = -x
|
|
@@ -330,17 +329,17 @@ class DiGamma(Cell):
|
|
|
330
329
|
self.log_lanczos_gamma_plus_one_half = np.log(self.lanczos_gamma_plus_one_half)
|
|
331
330
|
|
|
332
331
|
# operations
|
|
333
|
-
self.log1p =
|
|
334
|
-
self.abs =
|
|
335
|
-
self.shape =
|
|
336
|
-
self.dtype =
|
|
337
|
-
self.floor =
|
|
338
|
-
self.equal =
|
|
339
|
-
self.less =
|
|
340
|
-
self.select =
|
|
341
|
-
self.sin =
|
|
342
|
-
self.cos =
|
|
343
|
-
self.logicaland =
|
|
332
|
+
self.log1p = ops.Log1p()
|
|
333
|
+
self.abs = ops.Abs()
|
|
334
|
+
self.shape = ops.Shape()
|
|
335
|
+
self.dtype = ops.DType()
|
|
336
|
+
self.floor = ops.Floor()
|
|
337
|
+
self.equal = ops.Equal()
|
|
338
|
+
self.less = ops.Less()
|
|
339
|
+
self.select = ops.Select()
|
|
340
|
+
self.sin = ops.Sin()
|
|
341
|
+
self.cos = ops.Cos()
|
|
342
|
+
self.logicaland = ops.LogicalAnd()
|
|
344
343
|
|
|
345
344
|
def construct(self, x):
|
|
346
345
|
input_dtype = self.dtype(x)
|
|
@@ -369,7 +368,7 @@ class DiGamma(Cell):
|
|
|
369
368
|
reduced_input = x + self.abs(self.floor(x + 0.5))
|
|
370
369
|
reflection = y - self.pi * self.cos(self.pi * reduced_input) / self.sin(self.pi * reduced_input)
|
|
371
370
|
real_result = self.select(need_to_reflect, reflection, y)
|
|
372
|
-
nan =
|
|
371
|
+
nan = ops.fill(self.dtype(x), self.shape(x), np.nan)
|
|
373
372
|
|
|
374
373
|
return self.select(self.logicaland(self.less(x, 0), self.equal(x, self.floor(x))),
|
|
375
374
|
nan, real_result)
|
|
@@ -384,11 +383,11 @@ def _while_helper_func(cond, body, vals):
|
|
|
384
383
|
def _igamma_series(ax, x, a, enabled):
|
|
385
384
|
"""Helper function for computing Igamma using a power series."""
|
|
386
385
|
|
|
387
|
-
logicaland =
|
|
388
|
-
greater =
|
|
389
|
-
shape =
|
|
390
|
-
dtype =
|
|
391
|
-
select =
|
|
386
|
+
logicaland = ops.LogicalAnd()
|
|
387
|
+
greater = ops.Greater()
|
|
388
|
+
shape = ops.Shape()
|
|
389
|
+
dtype = ops.DType()
|
|
390
|
+
select = ops.Select()
|
|
392
391
|
|
|
393
392
|
# If more data types are supported, this epsilon need to be selected.
|
|
394
393
|
epsilon = Tensor(np.finfo(np.float32).eps, mstype.float32)
|
|
@@ -418,8 +417,8 @@ def _igamma_series(ax, x, a, enabled):
|
|
|
418
417
|
select(enabled, x, vals[4]), select(enabled, dc_da, vals[5]),
|
|
419
418
|
select(enabled, dans_da, vals[6]))
|
|
420
419
|
|
|
421
|
-
ones =
|
|
422
|
-
zeros =
|
|
420
|
+
ones = ops.fill(dtype(a), shape(a), 1)
|
|
421
|
+
zeros = ops.fill(dtype(a), shape(a), 0)
|
|
423
422
|
vals = (enabled, a, ones, ones, x, zeros, zeros)
|
|
424
423
|
|
|
425
424
|
vals = _while_helper_func(cond, body, vals)
|
|
@@ -430,14 +429,14 @@ def _igamma_series(ax, x, a, enabled):
|
|
|
430
429
|
def _igammac_continued_fraction(ax, x, a, enabled):
|
|
431
430
|
"""Helper function for computing Igammac using a continued fraction."""
|
|
432
431
|
|
|
433
|
-
abs_x =
|
|
434
|
-
logicaland =
|
|
435
|
-
greater =
|
|
436
|
-
less =
|
|
437
|
-
notequal =
|
|
438
|
-
shape =
|
|
439
|
-
dtype =
|
|
440
|
-
select =
|
|
432
|
+
abs_x = ops.Abs()
|
|
433
|
+
logicaland = ops.LogicalAnd()
|
|
434
|
+
greater = ops.Greater()
|
|
435
|
+
less = ops.Less()
|
|
436
|
+
notequal = ops.NotEqual()
|
|
437
|
+
shape = ops.Shape()
|
|
438
|
+
dtype = ops.DType()
|
|
439
|
+
select = ops.Select()
|
|
441
440
|
|
|
442
441
|
# If more data types are supported, this epsilon need to be selected.
|
|
443
442
|
epsilon = Tensor(np.finfo(np.float32).eps, mstype.float32)
|
|
@@ -475,7 +474,7 @@ def _igammac_continued_fraction(ax, x, a, enabled):
|
|
|
475
474
|
qk_is_nonzero = notequal(qk, 0)
|
|
476
475
|
r = pk / qk
|
|
477
476
|
|
|
478
|
-
t = select(qk_is_nonzero, abs_x((ans - r) / r),
|
|
477
|
+
t = select(qk_is_nonzero, abs_x((ans - r) / r), ops.fill(dtype(t), shape(t), 1))
|
|
479
478
|
ans = select(qk_is_nonzero, r, ans)
|
|
480
479
|
|
|
481
480
|
dpk_da = dpkm1_da * z - pkm1 - dpkm2_da * yc + pkm2 * c
|
|
@@ -483,7 +482,7 @@ def _igammac_continued_fraction(ax, x, a, enabled):
|
|
|
483
482
|
dans_da_new = select(qk_is_nonzero, (dpk_da - ans * dqk_da) / qk, dans_da)
|
|
484
483
|
grad_conditional = select(qk_is_nonzero,
|
|
485
484
|
abs_x(dans_da_new - dans_da),
|
|
486
|
-
|
|
485
|
+
ops.fill(dtype(dans_da), shape(dans_da), 1))
|
|
487
486
|
|
|
488
487
|
pkm2 = pkm1
|
|
489
488
|
pkm1 = pk
|
|
@@ -518,16 +517,16 @@ def _igammac_continued_fraction(ax, x, a, enabled):
|
|
|
518
517
|
|
|
519
518
|
y = 1 - a
|
|
520
519
|
z = x + y + 1
|
|
521
|
-
c =
|
|
522
|
-
pkm2 =
|
|
520
|
+
c = ops.fill(dtype(x), shape(x), 0)
|
|
521
|
+
pkm2 = ops.fill(dtype(x), shape(x), 1)
|
|
523
522
|
qkm2 = x
|
|
524
523
|
pkm1 = x + 1
|
|
525
524
|
qkm1 = z * x
|
|
526
525
|
ans = pkm1 / qkm1
|
|
527
|
-
t =
|
|
528
|
-
dpkm2_da =
|
|
529
|
-
dqkm2_da =
|
|
530
|
-
dpkm1_da =
|
|
526
|
+
t = ops.fill(dtype(x), shape(x), 1)
|
|
527
|
+
dpkm2_da = ops.fill(dtype(x), shape(x), 0)
|
|
528
|
+
dqkm2_da = ops.fill(dtype(x), shape(x), 0)
|
|
529
|
+
dpkm1_da = ops.fill(dtype(x), shape(x), 0)
|
|
531
530
|
dqkm1_da = -x
|
|
532
531
|
dans_da = (dpkm1_da - ans * dqkm1_da) / qkm1
|
|
533
532
|
vals = (enabled, ans, t, y, z, c, pkm1, qkm1, pkm2, qkm2, dpkm2_da, dqkm2_da, dpkm1_da, dqkm1_da, dans_da)
|
|
@@ -588,21 +587,21 @@ class IGamma(Cell):
|
|
|
588
587
|
self.log_maxfloat32 = Tensor(np.log(np.finfo(np.float32).max), mstype.float32)
|
|
589
588
|
|
|
590
589
|
# operations
|
|
591
|
-
self.logicaland =
|
|
592
|
-
self.logicalor =
|
|
593
|
-
self.logicalnot =
|
|
594
|
-
self.equal =
|
|
595
|
-
self.greater =
|
|
596
|
-
self.less =
|
|
597
|
-
self.neg =
|
|
598
|
-
self.log =
|
|
599
|
-
self.exp =
|
|
600
|
-
self.select =
|
|
601
|
-
self.zeroslike =
|
|
602
|
-
self.shape =
|
|
603
|
-
self.dtype =
|
|
590
|
+
self.logicaland = ops.LogicalAnd()
|
|
591
|
+
self.logicalor = ops.LogicalOr()
|
|
592
|
+
self.logicalnot = ops.LogicalNot()
|
|
593
|
+
self.equal = ops.Equal()
|
|
594
|
+
self.greater = ops.Greater()
|
|
595
|
+
self.less = ops.Less()
|
|
596
|
+
self.neg = ops.Neg()
|
|
597
|
+
self.log = ops.Log()
|
|
598
|
+
self.exp = ops.Exp()
|
|
599
|
+
self.select = ops.Select()
|
|
600
|
+
self.zeroslike = ops.ZerosLike()
|
|
601
|
+
self.shape = ops.Shape()
|
|
602
|
+
self.dtype = ops.DType()
|
|
604
603
|
self.lgamma = LGamma()
|
|
605
|
-
self.cast =
|
|
604
|
+
self.cast = ops.Cast()
|
|
606
605
|
|
|
607
606
|
def construct(self, a, x):
|
|
608
607
|
a_dtype = self.dtype(a)
|
|
@@ -614,8 +613,8 @@ class IGamma(Cell):
|
|
|
614
613
|
ax = a * self.log(x) - x - self.lgamma(a)
|
|
615
614
|
para_shape = self.shape(ax)
|
|
616
615
|
if para_shape != ():
|
|
617
|
-
x =
|
|
618
|
-
a =
|
|
616
|
+
x = ops.broadcast_to(x, para_shape)
|
|
617
|
+
a = ops.broadcast_to(a, para_shape)
|
|
619
618
|
x_is_zero = self.equal(x, 0)
|
|
620
619
|
underflow = self.less(ax, self.neg(self.log_maxfloat32))
|
|
621
620
|
ax = self.exp(ax)
|
|
@@ -624,7 +623,7 @@ class IGamma(Cell):
|
|
|
624
623
|
1 - _igammac_continued_fraction(ax, x, a, self.logicaland(enabled, use_igammac)),
|
|
625
624
|
_igamma_series(ax, x, a, self.logicaland(enabled, self.logicalnot(use_igammac))))
|
|
626
625
|
output = self.select(x_is_zero, self.zeroslike(output), output)
|
|
627
|
-
output = self.select(domain_error,
|
|
626
|
+
output = self.select(domain_error, ops.fill(self.dtype(a), self.shape(a), np.nan), output)
|
|
628
627
|
return output
|
|
629
628
|
|
|
630
629
|
|
|
@@ -682,14 +681,14 @@ class LBeta(Cell):
|
|
|
682
681
|
0.833333333333333e-01]
|
|
683
682
|
|
|
684
683
|
# operations
|
|
685
|
-
self.log =
|
|
686
|
-
self.log1p =
|
|
687
|
-
self.less =
|
|
688
|
-
self.select =
|
|
689
|
-
self.shape =
|
|
690
|
-
self.dtype =
|
|
684
|
+
self.log = ops.Log()
|
|
685
|
+
self.log1p = ops.Log1p()
|
|
686
|
+
self.less = ops.Less()
|
|
687
|
+
self.select = ops.Select()
|
|
688
|
+
self.shape = ops.Shape()
|
|
689
|
+
self.dtype = ops.DType()
|
|
691
690
|
self.lgamma = LGamma()
|
|
692
|
-
self.const =
|
|
691
|
+
self.const = ops.ScalarToTensor()
|
|
693
692
|
|
|
694
693
|
def construct(self, x, y):
|
|
695
694
|
x_dtype = self.dtype(x)
|
|
@@ -699,8 +698,8 @@ class LBeta(Cell):
|
|
|
699
698
|
x_plus_y = x + y
|
|
700
699
|
para_shape = self.shape(x_plus_y)
|
|
701
700
|
if para_shape != ():
|
|
702
|
-
x =
|
|
703
|
-
y =
|
|
701
|
+
x = ops.broadcast_to(x, para_shape)
|
|
702
|
+
y = ops.broadcast_to(y, para_shape)
|
|
704
703
|
comp_less = self.less(x, y)
|
|
705
704
|
x_min = self.select(comp_less, x, y)
|
|
706
705
|
y_max = self.select(comp_less, y, x)
|
|
@@ -805,17 +804,17 @@ def matmul_op_select(x1_shape, x2_shape, transpose_x1, transpose_x2):
|
|
|
805
804
|
"""select matmul op"""
|
|
806
805
|
x1_dim, x2_dim = len(x1_shape), len(x2_shape)
|
|
807
806
|
if x1_dim == 1 and x2_dim == 1:
|
|
808
|
-
matmul_op =
|
|
807
|
+
matmul_op = ops.Mul()
|
|
809
808
|
elif x1_dim <= 2 and x2_dim <= 2:
|
|
810
809
|
transpose_x1 = False if x1_dim == 1 else transpose_x1
|
|
811
810
|
transpose_x2 = False if x2_dim == 1 else transpose_x2
|
|
812
|
-
matmul_op =
|
|
811
|
+
matmul_op = ops.MatMul(transpose_x1, transpose_x2)
|
|
813
812
|
elif x1_dim == 1 and x2_dim > 2:
|
|
814
|
-
matmul_op =
|
|
813
|
+
matmul_op = ops.BatchMatMul(False, transpose_x2)
|
|
815
814
|
elif x1_dim > 2 and x2_dim == 1:
|
|
816
|
-
matmul_op =
|
|
815
|
+
matmul_op = ops.BatchMatMul(transpose_x1, False)
|
|
817
816
|
else:
|
|
818
|
-
matmul_op =
|
|
817
|
+
matmul_op = ops.BatchMatMul(transpose_x1, transpose_x2)
|
|
819
818
|
return matmul_op
|
|
820
819
|
|
|
821
820
|
|
|
@@ -836,11 +835,11 @@ class MatMul(Cell):
|
|
|
836
835
|
validator.check_value_type('transpose_x2', transpose_x2, [bool], self.cls_name)
|
|
837
836
|
self.transpose_x1 = transpose_x1
|
|
838
837
|
self.transpose_x2 = transpose_x2
|
|
839
|
-
self.shape_op =
|
|
840
|
-
self.expand_op =
|
|
841
|
-
self.squeeze_left_op =
|
|
842
|
-
self.squeeze_right_op =
|
|
843
|
-
self.reduce_sum_op =
|
|
838
|
+
self.shape_op = ops.Shape()
|
|
839
|
+
self.expand_op = ops.ExpandDims()
|
|
840
|
+
self.squeeze_left_op = ops.Squeeze(-2)
|
|
841
|
+
self.squeeze_right_op = ops.Squeeze(-1)
|
|
842
|
+
self.reduce_sum_op = ops.ReduceSum(keep_dims=False)
|
|
844
843
|
|
|
845
844
|
def construct(self, x1, x2):
|
|
846
845
|
x1_shape = self.shape_op(x1)
|
|
@@ -860,9 +859,9 @@ class MatMul(Cell):
|
|
|
860
859
|
|
|
861
860
|
x1_broadcast_shape, x2_broadcast_shape = get_broadcast_matmul_shape(x1_shape, x2_shape)
|
|
862
861
|
if x1_broadcast_shape != x1_shape:
|
|
863
|
-
x1 =
|
|
862
|
+
x1 = ops.broadcast_to(x1, x1_broadcast_shape)
|
|
864
863
|
if x2_broadcast_shape != x2_shape:
|
|
865
|
-
x2 =
|
|
864
|
+
x2 = ops.broadcast_to(x2, x2_broadcast_shape)
|
|
866
865
|
|
|
867
866
|
matmul_broadcast = matmul_op(x1, x2)
|
|
868
867
|
|
|
@@ -921,10 +920,10 @@ class CosineSimilarity(Cell):
|
|
|
921
920
|
super().__init__()
|
|
922
921
|
self.dim = dim
|
|
923
922
|
self.eps = eps
|
|
924
|
-
self.mul =
|
|
925
|
-
self.div =
|
|
926
|
-
self.maximum =
|
|
927
|
-
self.cast =
|
|
923
|
+
self.mul = ops.Mul()
|
|
924
|
+
self.div = ops.DivNoNan()
|
|
925
|
+
self.maximum = ops.Maximum()
|
|
926
|
+
self.cast = ops.Cast()
|
|
928
927
|
|
|
929
928
|
def construct(self, x1, x2):
|
|
930
929
|
if not isinstance(x1, Tensor):
|
|
@@ -959,18 +958,18 @@ class Moments(Cell):
|
|
|
959
958
|
if keep_dims is None:
|
|
960
959
|
keep_dims = False
|
|
961
960
|
self.keep_dims = validator.check_value_type('keep_dims', keep_dims, [bool], self.cls_name)
|
|
962
|
-
self.cast =
|
|
963
|
-
self.reduce_mean =
|
|
964
|
-
self.square_diff =
|
|
965
|
-
self.squeeze =
|
|
961
|
+
self.cast = ops.Cast()
|
|
962
|
+
self.reduce_mean = ops.ReduceMean(keep_dims=True)
|
|
963
|
+
self.square_diff = ops.SquaredDifference()
|
|
964
|
+
self.squeeze = ops.Squeeze(self.axis)
|
|
966
965
|
|
|
967
966
|
def construct(self, x):
|
|
968
|
-
tensor_dtype =
|
|
967
|
+
tensor_dtype = ops.dtype(x)
|
|
969
968
|
_check_input_dtype("input x", tensor_dtype, [mstype.float16, mstype.float32], self.cls_name)
|
|
970
969
|
if tensor_dtype == mstype.float16:
|
|
971
970
|
x = self.cast(x, mstype.float32)
|
|
972
971
|
mean = self.reduce_mean(x, self.axis)
|
|
973
|
-
variance = self.reduce_mean(self.square_diff(x,
|
|
972
|
+
variance = self.reduce_mean(self.square_diff(x, ops.stop_gradient(mean)), self.axis)
|
|
974
973
|
if not self.keep_dims:
|
|
975
974
|
mean = self.squeeze(mean)
|
|
976
975
|
variance = self.squeeze(variance)
|
|
@@ -1013,8 +1012,8 @@ class MatInverse(Cell):
|
|
|
1013
1012
|
def __init__(self):
|
|
1014
1013
|
"""Initialize MatInverse."""
|
|
1015
1014
|
super(MatInverse, self).__init__()
|
|
1016
|
-
self.dtype =
|
|
1017
|
-
self.choleskytrsm =
|
|
1015
|
+
self.dtype = ops.DType()
|
|
1016
|
+
self.choleskytrsm = ops.operations.CholeskyTrsm()
|
|
1018
1017
|
self.matmul = MatMul(transpose_x1=True)
|
|
1019
1018
|
|
|
1020
1019
|
def construct(self, a):
|
|
@@ -1055,10 +1054,10 @@ class MatDet(Cell):
|
|
|
1055
1054
|
def __init__(self):
|
|
1056
1055
|
"""Initialize MatDet."""
|
|
1057
1056
|
super(MatDet, self).__init__()
|
|
1058
|
-
self.dtype =
|
|
1059
|
-
self.cholesky =
|
|
1060
|
-
self.det_triangle =
|
|
1061
|
-
self.square =
|
|
1057
|
+
self.dtype = ops.DType()
|
|
1058
|
+
self.cholesky = ops.Cholesky()
|
|
1059
|
+
self.det_triangle = ops.operations.DetTriangle()
|
|
1060
|
+
self.square = ops.Square()
|
|
1062
1061
|
|
|
1063
1062
|
def construct(self, a):
|
|
1064
1063
|
input_dtype = self.dtype(a)
|