mindspore 2.7.0__cp310-cp310-win_amd64.whl → 2.7.0rc1__cp310-cp310-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 +1 -1
- mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +2 -2
- mindspore/_extends/builtin_operations.py +3 -3
- mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
- mindspore/_extends/parse/__init__.py +3 -3
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -0
- mindspore/_extends/parse/parser.py +22 -28
- mindspore/_extends/parse/standard_method.py +1 -15
- mindspore/_extends/pijit/pijit_func_white_list.py +5 -2
- mindspore/_extends/remote/kernel_build_server_ascend.py +75 -0
- mindspore/amp.py +18 -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/common/__init__.py +12 -18
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +38 -102
- mindspore/common/_utils.py +1 -9
- mindspore/common/api.py +106 -155
- mindspore/common/{dynamic_shape/auto_dynamic_shape.py → auto_dynamic_shape.py} +23 -17
- mindspore/common/dtype.py +57 -98
- mindspore/common/dump.py +1 -1
- mindspore/common/file_system.py +9 -59
- mindspore/common/hook_handle.py +3 -22
- mindspore/common/np_dtype.py +3 -3
- mindspore/common/parameter.py +20 -4
- mindspore/common/recompute.py +4 -2
- mindspore/common/tensor.py +52 -38
- mindspore/communication/_hccl_management.py +297 -0
- mindspore/context.py +21 -15
- mindspore/dataset/__init__.py +1 -1
- mindspore/dataset/audio/transforms.py +1 -1
- mindspore/dataset/core/config.py +1 -35
- mindspore/dataset/engine/datasets.py +315 -330
- mindspore/dataset/engine/datasets_user_defined.py +22 -38
- mindspore/dataset/transforms/c_transforms.py +2 -2
- mindspore/dataset/transforms/transforms.py +3 -3
- mindspore/dataset/vision/__init__.py +1 -1
- mindspore/dataset/vision/py_transforms.py +8 -8
- mindspore/dataset/vision/transforms.py +5 -17
- mindspore/dataset/vision/utils.py +21 -632
- mindspore/device_context/ascend/op_tuning.py +1 -35
- mindspore/dnnl.dll +0 -0
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +0 -3
- mindspore/include/api/cell.h +4 -28
- mindspore/include/api/cfg.h +7 -24
- mindspore/include/api/context.h +0 -1
- mindspore/include/api/delegate.h +2 -0
- mindspore/include/api/dual_abi_helper.h +19 -100
- mindspore/include/api/graph.h +1 -14
- mindspore/include/api/kernel.h +3 -16
- mindspore/include/api/kernel_api.h +1 -9
- mindspore/include/api/metrics/accuracy.h +0 -9
- mindspore/include/api/model.h +1 -5
- mindspore/include/api/model_group.h +0 -4
- mindspore/include/api/model_parallel_runner.h +0 -2
- mindspore/include/api/status.h +10 -48
- mindspore/include/api/types.h +1 -6
- mindspore/include/dataset/constants.h +0 -9
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/cifar10.py +2 -3
- mindspore/mindrecord/tools/cifar10_to_mr.py +5 -5
- 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/distributed/__init__.py +0 -4
- mindspore/mint/distributed/distributed.py +14 -217
- mindspore/mint/nn/layer/_functions.py +2 -1
- mindspore/mint/nn/layer/conv.py +6 -6
- mindspore/mint/nn/layer/normalization.py +3 -3
- mindspore/nn/cell.py +174 -216
- mindspore/nn/layer/activation.py +2 -4
- mindspore/nn/layer/basic.py +13 -7
- mindspore/nn/layer/image.py +1 -1
- mindspore/nn/optim/adam.py +3 -1
- mindspore/nn/optim/lamb.py +3 -1
- mindspore/nn/optim/tft_wrapper.py +3 -2
- mindspore/nn/probability/distribution/_utils/utils.py +2 -2
- mindspore/nn/wrap/cell_wrapper.py +5 -39
- mindspore/nn/wrap/grad_reducer.py +15 -0
- mindspore/numpy/array_creations.py +2 -2
- 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_inner_ops.py +9 -0
- mindspore/ops/_op_impl/cpu/__init__.py +0 -1
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +2 -12
- mindspore/ops/auto_generate/gen_extend_func.py +4 -4
- mindspore/ops/auto_generate/gen_ops_def.py +16 -290
- mindspore/ops/auto_generate/gen_ops_prim.py +76 -563
- mindspore/ops/composite/base.py +1 -1
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
- mindspore/ops/function/__init__.py +0 -1
- mindspore/ops/function/array_func.py +6 -10
- mindspore/ops/function/debug_func.py +2 -4
- mindspore/ops/function/grad/grad_func.py +12 -4
- mindspore/ops/function/math_func.py +32 -44
- mindspore/ops/function/nn_func.py +20 -18
- mindspore/ops/functional.py +1 -2
- mindspore/ops/functional_overload.py +12 -23
- mindspore/ops/operations/_inner_ops.py +12 -11
- mindspore/ops/operations/array_ops.py +50 -4
- mindspore/ops/operations/comm_ops.py +15 -1
- mindspore/ops/operations/custom_ops.py +4 -10
- mindspore/ops/operations/debug_ops.py +6 -6
- mindspore/ops/operations/manually_defined/ops_def.py +12 -12
- mindspore/ops/operations/math_ops.py +5 -5
- mindspore/ops/operations/nn_ops.py +1 -1
- mindspore/ops/primitive.py +10 -3
- mindspore/ops/tensor_method.py +7 -16
- mindspore/ops_generate/pyboost/gen_pyboost_func.py +16 -0
- mindspore/parallel/_auto_parallel_context.py +15 -5
- mindspore/parallel/_parallel_serialization.py +2 -3
- mindspore/parallel/_ps_context.py +2 -2
- mindspore/parallel/_transformer/transformer.py +4 -4
- mindspore/parallel/_utils.py +11 -5
- mindspore/parallel/auto_parallel.py +9 -23
- mindspore/parallel/checkpoint_transform.py +0 -2
- mindspore/parallel/cluster/process_entity/_api.py +1 -4
- mindspore/parallel/cluster/run.py +3 -5
- mindspore/parallel/function/reshard_func.py +5 -6
- mindspore/parallel/nn/parallel_cell_wrapper.py +3 -40
- mindspore/parallel/nn/parallel_grad_reducer.py +8 -0
- mindspore/parallel/shard.py +21 -7
- mindspore/parallel/transform_safetensors.py +4 -10
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +9 -10
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +1 -1
- mindspore/profiler/common/msprof_cmd_tool.py +2 -2
- mindspore/profiler/common/path_manager.py +0 -9
- mindspore/profiler/common/profiler_context.py +2 -25
- mindspore/profiler/common/profiler_meta_data.py +0 -1
- mindspore/profiler/common/profiler_op_analyse.py +6 -10
- mindspore/{ops/_op_impl/cpu/joinedstr_op.py → profiler/common/validator/__init__.py} +1 -15
- mindspore/profiler/common/validator/validate_path.py +84 -0
- mindspore/profiler/dynamic_profiler.py +46 -91
- mindspore/profiler/envprofiler.py +5 -30
- mindspore/profiler/experimental_config.py +1 -16
- mindspore/profiler/platform/cpu_profiler.py +4 -10
- mindspore/profiler/platform/npu_profiler.py +1 -1
- mindspore/profiler/profiler.py +145 -193
- mindspore/profiler/profiler_action_controller.py +1 -1
- mindspore/profiler/profiler_interface.py +2 -2
- mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
- mindspore/runtime/__init__.py +4 -6
- mindspore/runtime/executor.py +0 -27
- mindspore/runtime/memory.py +0 -1
- mindspore/runtime/thread_bind_core.py +1 -1
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +3 -3
- mindspore/train/amp.py +3 -0
- mindspore/train/callback/_callback.py +1 -2
- mindspore/train/callback/_checkpoint.py +8 -1
- mindspore/train/callback/_flops_collector.py +6 -10
- mindspore/train/callback/_train_fault_tolerance.py +7 -3
- mindspore/train/data_sink.py +4 -4
- mindspore/train/dataset_helper.py +5 -5
- mindspore/train/model.py +20 -4
- mindspore/train/serialization.py +15 -35
- mindspore/train/train_thor/model_thor.py +2 -2
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/hooks.py +81 -0
- mindspore/utils/utils.py +8 -8
- mindspore/version.py +1 -1
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +1 -1
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +193 -192
- mindspore/_extends/parallel_compile/akg_compiler/custom.py +0 -1109
- mindspore/common/dynamic_shape/__init__.py +0 -0
- mindspore/common/dynamic_shape/enable_dynamic.py +0 -197
- /mindspore/common/{dynamic_shape/_auto_dynamic.py → _auto_dynamic.py} +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
mindspore/common/dtype.py
CHANGED
|
@@ -17,25 +17,21 @@
|
|
|
17
17
|
"""Data type for MindSpore."""
|
|
18
18
|
from __future__ import absolute_import
|
|
19
19
|
|
|
20
|
-
import builtins
|
|
21
20
|
import enum
|
|
22
21
|
from inspect import isfunction
|
|
23
22
|
import numpy as np
|
|
24
|
-
from mindspore import log as logger
|
|
25
23
|
from mindspore._c_expression import typing
|
|
26
24
|
from mindspore._c_expression.typing import Type
|
|
27
|
-
from mindspore._c_expression.np_dtypes import
|
|
25
|
+
from mindspore._c_expression.np_dtypes import np_version_valid
|
|
28
26
|
|
|
29
|
-
if
|
|
27
|
+
if np_version_valid(False):
|
|
30
28
|
from mindspore._c_expression.np_dtypes import bfloat16 as np_bfloat16
|
|
31
29
|
|
|
32
|
-
# bool, int, float are not defined in __all__ to avoid conflict with built-in types.
|
|
33
30
|
__dtype__ = [
|
|
34
|
-
"bool_",
|
|
35
31
|
"int8", "byte",
|
|
36
32
|
"int16", "short",
|
|
37
33
|
"int32", "intc",
|
|
38
|
-
"int64", "
|
|
34
|
+
"int64", "intp",
|
|
39
35
|
"uint8", "ubyte",
|
|
40
36
|
"uint16", "ushort",
|
|
41
37
|
"uint32", "uintc",
|
|
@@ -43,15 +39,17 @@ __dtype__ = [
|
|
|
43
39
|
"float16", "half",
|
|
44
40
|
"float32", "single",
|
|
45
41
|
"float64", "double",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"float8_e4m3fn", "float8_e5m2", "hifloat8",
|
|
50
|
-
"int_", "uint", "float_",
|
|
51
|
-
"list_", "tuple_", "string",
|
|
42
|
+
"bool_", "float_",
|
|
43
|
+
"list_", "tuple_",
|
|
44
|
+
"int_", "uint",
|
|
52
45
|
"number", "tensor_type",
|
|
53
|
-
"
|
|
54
|
-
"TensorType", "
|
|
46
|
+
"string", "type_none",
|
|
47
|
+
"TensorType", "_null",
|
|
48
|
+
"Type", "Int",
|
|
49
|
+
"complex64", "complex128",
|
|
50
|
+
"bfloat16", "qint4x2",
|
|
51
|
+
"float8_e4m3fn", "float8_e5m2",
|
|
52
|
+
"hifloat8"
|
|
55
53
|
]
|
|
56
54
|
|
|
57
55
|
__method__ = [
|
|
@@ -64,18 +62,16 @@ __all__.extend(__dtype__)
|
|
|
64
62
|
__all__.extend(__method__)
|
|
65
63
|
|
|
66
64
|
# type definition
|
|
67
|
-
|
|
68
|
-
bool_ = bool
|
|
65
|
+
bool_ = typing.kBool
|
|
69
66
|
|
|
67
|
+
qint4x2 = typing.kInt4
|
|
70
68
|
int8 = typing.kInt8
|
|
71
69
|
byte = int8
|
|
72
70
|
int16 = typing.kInt16
|
|
73
71
|
short = int16
|
|
74
72
|
int32 = typing.kInt32
|
|
75
|
-
int = int32
|
|
76
73
|
intc = int32
|
|
77
74
|
int64 = typing.kInt64
|
|
78
|
-
long = int64
|
|
79
75
|
intp = int64
|
|
80
76
|
|
|
81
77
|
uint8 = typing.kUInt8
|
|
@@ -90,21 +86,15 @@ uintp = uint64
|
|
|
90
86
|
float16 = typing.kFloat16
|
|
91
87
|
half = float16
|
|
92
88
|
float32 = typing.kFloat32
|
|
93
|
-
float = float32
|
|
94
89
|
single = float32
|
|
95
90
|
float64 = typing.kFloat64
|
|
96
91
|
double = float64
|
|
97
|
-
|
|
98
|
-
qint4x2 = typing.kInt4
|
|
99
92
|
float8_e4m3fn = typing.kFloat8E4M3FN
|
|
100
93
|
float8_e5m2 = typing.kFloat8E5M2
|
|
101
94
|
hifloat8 = typing.kHiFloat8
|
|
102
95
|
bfloat16 = typing.kBFloat16
|
|
103
|
-
|
|
104
96
|
complex64 = typing.kComplex64
|
|
105
|
-
cfloat = complex64
|
|
106
97
|
complex128 = typing.kComplex128
|
|
107
|
-
cdouble = complex128
|
|
108
98
|
|
|
109
99
|
number = typing.kNumber
|
|
110
100
|
int_ = typing.kInt
|
|
@@ -147,25 +137,41 @@ AnythingType = typing.TypeAny
|
|
|
147
137
|
RefType = typing.RefType
|
|
148
138
|
_NullType = typing.TypeNull
|
|
149
139
|
|
|
150
|
-
number_type = (int8,
|
|
151
|
-
|
|
140
|
+
number_type = (int8,
|
|
141
|
+
int16,
|
|
142
|
+
int32,
|
|
143
|
+
int64,
|
|
144
|
+
uint8,
|
|
145
|
+
uint16,
|
|
146
|
+
uint32,
|
|
147
|
+
uint64,
|
|
148
|
+
float16,
|
|
149
|
+
float32,
|
|
150
|
+
float64,
|
|
151
|
+
bfloat16,
|
|
152
|
+
complex64,
|
|
153
|
+
complex128,
|
|
154
|
+
qint4x2,
|
|
155
|
+
float8_e4m3fn,
|
|
156
|
+
float8_e5m2,
|
|
157
|
+
hifloat8)
|
|
152
158
|
|
|
153
159
|
int_type = (int8, int16, int32, int64,)
|
|
154
160
|
uint_type = (uint8, uint16, uint32, uint64,)
|
|
155
161
|
float_type = (float16, float32, float64, bfloat16, float8_e4m3fn, float8_e5m2, hifloat8)
|
|
156
|
-
signed_type = (int8, int16, int32, int64,
|
|
157
|
-
float8_e4m3fn, float8_e5m2, hifloat8)
|
|
162
|
+
signed_type = (int8, byte, int16, short, int32, intc, int64, intp, float16, half, float32, single, float64, double,
|
|
163
|
+
bfloat16, complex64, complex128, float8_e4m3fn, float8_e5m2, hifloat8)
|
|
158
164
|
complex_type = (complex64, complex128,)
|
|
159
|
-
all_types = (
|
|
160
|
-
|
|
165
|
+
all_types = (bool_, int8, uint8, int16, int32, int64, float16, float32, float64, bfloat16, complex64, complex128,
|
|
166
|
+
float8_e4m3fn, float8_e5m2, hifloat8)
|
|
161
167
|
|
|
162
168
|
_simple_types = {
|
|
163
169
|
list: list_,
|
|
164
170
|
tuple: tuple_,
|
|
165
171
|
type(None): type_none,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
bool: bool_,
|
|
173
|
+
int: int64,
|
|
174
|
+
float: float64,
|
|
169
175
|
complex: complex128,
|
|
170
176
|
str: string,
|
|
171
177
|
np.bool_: bool_,
|
|
@@ -188,9 +194,6 @@ def pytype_to_dtype(obj):
|
|
|
188
194
|
"""
|
|
189
195
|
Convert python type to MindSpore type.
|
|
190
196
|
|
|
191
|
-
Note:
|
|
192
|
-
The interface is deprecated from version 2.7 and will be removed in a future version.
|
|
193
|
-
|
|
194
197
|
Args:
|
|
195
198
|
obj (type): A python type object.
|
|
196
199
|
|
|
@@ -206,15 +209,6 @@ def pytype_to_dtype(obj):
|
|
|
206
209
|
>>> print(out)
|
|
207
210
|
Bool
|
|
208
211
|
"""
|
|
209
|
-
logger.warning("The interface 'mindspore.pytype_to_dtype' is deprecated from version 2.7 "
|
|
210
|
-
"and will be removed in a future version.")
|
|
211
|
-
return _pytype_to_dtype(obj)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
def _pytype_to_dtype(obj):
|
|
215
|
-
"""
|
|
216
|
-
Convert python type to MindSpore type.
|
|
217
|
-
"""
|
|
218
212
|
|
|
219
213
|
if isinstance(obj, np.dtype):
|
|
220
214
|
obj = obj.type
|
|
@@ -232,9 +226,6 @@ def get_py_obj_dtype(obj):
|
|
|
232
226
|
"""
|
|
233
227
|
Get the MindSpore data type, which corresponds to python type or variable.
|
|
234
228
|
|
|
235
|
-
Note:
|
|
236
|
-
The interface is deprecated from version 2.7 and will be removed in a future version.
|
|
237
|
-
|
|
238
229
|
Args:
|
|
239
230
|
obj (type): An object of python type, or a variable of python type.
|
|
240
231
|
|
|
@@ -246,15 +237,6 @@ def get_py_obj_dtype(obj):
|
|
|
246
237
|
>>> ms.get_py_obj_dtype(1)
|
|
247
238
|
mindspore.int64
|
|
248
239
|
"""
|
|
249
|
-
logger.warning("The interface 'mindspore.get_py_obj_dtype' is deprecated from version 2.7 "
|
|
250
|
-
"and will be removed in a future version.")
|
|
251
|
-
return _get_py_obj_dtype(obj)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
def _get_py_obj_dtype(obj):
|
|
255
|
-
"""
|
|
256
|
-
Get the MindSpore data type, which corresponds to python type or variable.
|
|
257
|
-
"""
|
|
258
240
|
# Tensor
|
|
259
241
|
if hasattr(obj, 'shape') and hasattr(obj, 'dtype') and isinstance(obj.dtype, typing.Type):
|
|
260
242
|
return TensorType(obj.dtype)
|
|
@@ -278,9 +260,6 @@ def dtype_to_nptype(type_):
|
|
|
278
260
|
r"""
|
|
279
261
|
Convert MindSpore dtype to numpy data type.
|
|
280
262
|
|
|
281
|
-
Note:
|
|
282
|
-
The interface is deprecated from version 2.7 and will be removed in a future version.
|
|
283
|
-
|
|
284
263
|
Args:
|
|
285
264
|
type\_ (:class:`mindspore.dtype`): MindSpore's dtype.
|
|
286
265
|
|
|
@@ -292,15 +271,6 @@ def dtype_to_nptype(type_):
|
|
|
292
271
|
>>> ms.dtype_to_nptype(ms.int8)
|
|
293
272
|
<class 'numpy.int8'>
|
|
294
273
|
"""
|
|
295
|
-
logger.warning("The interface 'mindspore.dtype_to_nptype' is deprecated from version 2.7 "
|
|
296
|
-
"and will be removed in a future version.")
|
|
297
|
-
return _dtype_to_nptype(type_)
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
def _dtype_to_nptype(type_):
|
|
301
|
-
"""
|
|
302
|
-
Convert MindSpore dtype to numpy data type.
|
|
303
|
-
"""
|
|
304
274
|
_dtype_nptype_dict = {
|
|
305
275
|
bool_: np.bool_,
|
|
306
276
|
int8: np.int8,
|
|
@@ -318,7 +288,7 @@ def _dtype_to_nptype(type_):
|
|
|
318
288
|
complex128: np.complex128,
|
|
319
289
|
}
|
|
320
290
|
if type_ == bfloat16:
|
|
321
|
-
if not
|
|
291
|
+
if not np_version_valid(True):
|
|
322
292
|
raise TypeError(
|
|
323
293
|
"The Numpy bfloat16 data type is not supported now, please ensure that the current "
|
|
324
294
|
"Numpy version is not less than the version when the mindspore is compiled, "
|
|
@@ -332,9 +302,6 @@ def dtype_to_pytype(type_):
|
|
|
332
302
|
r"""
|
|
333
303
|
Convert MindSpore dtype to python data type.
|
|
334
304
|
|
|
335
|
-
Note:
|
|
336
|
-
The interface is deprecated from version 2.7 and will be removed in a future version.
|
|
337
|
-
|
|
338
305
|
Args:
|
|
339
306
|
type\_ (:class:`mindspore.dtype`): MindSpore's dtype.
|
|
340
307
|
|
|
@@ -347,31 +314,23 @@ def dtype_to_pytype(type_):
|
|
|
347
314
|
>>> print(out)
|
|
348
315
|
<class 'bool'>
|
|
349
316
|
"""
|
|
350
|
-
logger.warning("The interface 'mindspore.dtype_to_pytype' is deprecated from version 2.7 "
|
|
351
|
-
"and will be removed in a future version.")
|
|
352
|
-
return _dtype_to_pytype(type_)
|
|
353
|
-
|
|
354
317
|
|
|
355
|
-
def _dtype_to_pytype(type_):
|
|
356
|
-
"""
|
|
357
|
-
Convert MindSpore dtype to python data type.
|
|
358
|
-
"""
|
|
359
318
|
return {
|
|
360
|
-
bool_:
|
|
361
|
-
int_:
|
|
362
|
-
int8:
|
|
363
|
-
int16:
|
|
364
|
-
int32:
|
|
365
|
-
int64:
|
|
366
|
-
uint8:
|
|
367
|
-
uint16:
|
|
368
|
-
uint32:
|
|
369
|
-
uint64:
|
|
370
|
-
float_:
|
|
371
|
-
float16:
|
|
372
|
-
float32:
|
|
373
|
-
float64:
|
|
374
|
-
bfloat16:
|
|
319
|
+
bool_: bool,
|
|
320
|
+
int_: int,
|
|
321
|
+
int8: int,
|
|
322
|
+
int16: int,
|
|
323
|
+
int32: int,
|
|
324
|
+
int64: int,
|
|
325
|
+
uint8: int,
|
|
326
|
+
uint16: int,
|
|
327
|
+
uint32: int,
|
|
328
|
+
uint64: int,
|
|
329
|
+
float_: float,
|
|
330
|
+
float16: float,
|
|
331
|
+
float32: float,
|
|
332
|
+
float64: float,
|
|
333
|
+
bfloat16: float,
|
|
375
334
|
list_: list,
|
|
376
335
|
tuple_: tuple,
|
|
377
336
|
string: str,
|
|
@@ -458,7 +417,7 @@ class QuantDtype(enum.Enum):
|
|
|
458
417
|
def __str__(self):
|
|
459
418
|
return f"{self.name}"
|
|
460
419
|
|
|
461
|
-
def value(self) ->
|
|
420
|
+
def value(self) -> int:
|
|
462
421
|
"""
|
|
463
422
|
Return value of `QuantDtype`. This interface is currently used to serialize or deserialize `QuantDtype`
|
|
464
423
|
primarily.
|
mindspore/common/dump.py
CHANGED
|
@@ -68,7 +68,7 @@ def set_dump(target, enabled=True):
|
|
|
68
68
|
>>> import numpy as np
|
|
69
69
|
>>> import mindspore as ms
|
|
70
70
|
>>> import mindspore.nn as nn
|
|
71
|
-
>>> from mindspore import Tensor, set_dump
|
|
71
|
+
>>> from mindspore import Tensor, set_dump
|
|
72
72
|
>>>
|
|
73
73
|
>>> ms.set_device(device_target="Ascend")
|
|
74
74
|
>>>
|
mindspore/common/file_system.py
CHANGED
|
@@ -14,14 +14,10 @@
|
|
|
14
14
|
# ============================================================================
|
|
15
15
|
"""File system registration management"""
|
|
16
16
|
from mindspore import log as logger
|
|
17
|
-
from mindspore import _checkparam as Validator
|
|
18
|
-
|
|
19
|
-
mindio_server_info = {"memfs.data_block_pool_capacity_in_gb": "100"}
|
|
20
17
|
|
|
21
18
|
|
|
22
19
|
class FileSystem:
|
|
23
20
|
"""File operation interface manager"""
|
|
24
|
-
|
|
25
21
|
def __init__(self):
|
|
26
22
|
self.create = open
|
|
27
23
|
self.create_args = ("ab",)
|
|
@@ -39,33 +35,20 @@ def _register_basic_file_system(fs: FileSystem):
|
|
|
39
35
|
return True
|
|
40
36
|
|
|
41
37
|
|
|
42
|
-
def
|
|
43
|
-
"""
|
|
38
|
+
def _register_mindio_file_system(fs: FileSystem):
|
|
39
|
+
"""register mindio file system"""
|
|
44
40
|
try:
|
|
45
|
-
import
|
|
46
|
-
ret = mindio.initialize(server_info=mindio_server_info)
|
|
47
|
-
if ret == 0:
|
|
48
|
-
return mindio
|
|
49
|
-
logger.warning(f"Failed to initialize mindio_acp: ret = {ret}")
|
|
41
|
+
import mindio
|
|
50
42
|
except ImportError:
|
|
51
|
-
|
|
43
|
+
return False
|
|
52
44
|
try:
|
|
53
|
-
import mindio
|
|
54
45
|
ret = mindio.initialize()
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return None
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def _register_mindio_file_system(fs: FileSystem):
|
|
64
|
-
"""register mindio file system"""
|
|
65
|
-
mindio = _init_mindio()
|
|
66
|
-
if mindio is None:
|
|
46
|
+
except AttributeError as e:
|
|
47
|
+
logger.warning(f"Failed to initialize MindIO: {e}")
|
|
48
|
+
return False
|
|
49
|
+
if ret != 0:
|
|
50
|
+
logger.warning(f"Failed to initialize MindIO: ret = {ret}")
|
|
67
51
|
return False
|
|
68
|
-
|
|
69
52
|
fs.create = mindio.create_file
|
|
70
53
|
fs.create_args = ()
|
|
71
54
|
fs.open = mindio.open_file
|
|
@@ -73,36 +56,3 @@ def _register_mindio_file_system(fs: FileSystem):
|
|
|
73
56
|
fs.backend = "mindio"
|
|
74
57
|
logger.info("The weights are stored using MindIO as the backend.")
|
|
75
58
|
return True
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def set_mindio_server_info(data_block_pool_capacity_in_gb=100):
|
|
79
|
-
"""
|
|
80
|
-
Configure MindIO server settings.
|
|
81
|
-
|
|
82
|
-
Args:
|
|
83
|
-
data_block_pool_capacity_in_gb (int): Memory pool capacity for data blocks in gigabytes.
|
|
84
|
-
"""
|
|
85
|
-
global mindio_server_info
|
|
86
|
-
Validator.check_positive_int(data_block_pool_capacity_in_gb, "data_block_pool_capacity_in_gb")
|
|
87
|
-
mindio_server_info["memfs.data_block_pool_capacity_in_gb"] = str(data_block_pool_capacity_in_gb)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def mindio_preload(ckpt_file_name):
|
|
91
|
-
"""
|
|
92
|
-
Preload data into memory using MindIO for faster access.
|
|
93
|
-
|
|
94
|
-
Args:
|
|
95
|
-
ckpt_file_name (str): Checkpoint file name.
|
|
96
|
-
|
|
97
|
-
Returns:
|
|
98
|
-
bool: True if preloading is successful, False otherwise.
|
|
99
|
-
"""
|
|
100
|
-
Validator.check_value_type('ckpt_file_name', ckpt_file_name, str, "mindio_preload")
|
|
101
|
-
mindio = _init_mindio()
|
|
102
|
-
if mindio is None:
|
|
103
|
-
return False
|
|
104
|
-
if not hasattr(mindio, 'preload'):
|
|
105
|
-
logger.warning("MindIO module does not have preload method")
|
|
106
|
-
return False
|
|
107
|
-
mindio.preload(ckpt_file_name)
|
|
108
|
-
return True
|
mindspore/common/hook_handle.py
CHANGED
|
@@ -16,21 +16,6 @@
|
|
|
16
16
|
from __future__ import absolute_import
|
|
17
17
|
import weakref
|
|
18
18
|
from mindspore._c_expression import TensorPy as Tensor_
|
|
19
|
-
from mindspore._check_jit_forbidden_api import jit_forbidden_register
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# Global variable to mark the `Parameter` hook and `Cell` hook version
|
|
23
|
-
_HOOK_VERSION = 0
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def _update_hook_version():
|
|
27
|
-
global _HOOK_VERSION
|
|
28
|
-
_HOOK_VERSION += 1
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def _hook_version():
|
|
32
|
-
global _HOOK_VERSION
|
|
33
|
-
return _HOOK_VERSION
|
|
34
19
|
|
|
35
20
|
|
|
36
21
|
class _TensorHookHandle:
|
|
@@ -46,9 +31,8 @@ class _TensorHookHandle:
|
|
|
46
31
|
|
|
47
32
|
def __init__(self, tensor):
|
|
48
33
|
self.id = None
|
|
49
|
-
self.
|
|
34
|
+
self.tensor_ref = weakref.ref(tensor)
|
|
50
35
|
|
|
51
|
-
@jit_forbidden_register
|
|
52
36
|
def remove(self):
|
|
53
37
|
"""
|
|
54
38
|
Remove the tensor hook function, which corresponds to this '_TensorHookHandle' object.
|
|
@@ -83,9 +67,9 @@ class _TensorHookHandle:
|
|
|
83
67
|
"""
|
|
84
68
|
if self.id is not None:
|
|
85
69
|
Tensor_.remove_hook(self.id)
|
|
86
|
-
tensor = self.
|
|
70
|
+
tensor = self.tensor_ref()
|
|
87
71
|
if tensor is not None:
|
|
88
|
-
tensor._remove_hook()
|
|
72
|
+
tensor._remove_hook() # pylint:disable=protected-access
|
|
89
73
|
|
|
90
74
|
|
|
91
75
|
class HookHandle:
|
|
@@ -115,7 +99,6 @@ class HookHandle:
|
|
|
115
99
|
if extra_dict is not None:
|
|
116
100
|
self.extra_dict_ref = weakref.ref(extra_dict)
|
|
117
101
|
|
|
118
|
-
@jit_forbidden_register
|
|
119
102
|
def remove(self):
|
|
120
103
|
"""
|
|
121
104
|
Remove the cell hook function, which corresponds to this 'HookHandle' object.
|
|
@@ -162,8 +145,6 @@ class HookHandle:
|
|
|
162
145
|
(Tensor(shape=[1], dtype=Float32, value= [ 2.00000000e+00]), Tensor(shape=[1], dtype=Float32,
|
|
163
146
|
value= [ 2.00000000e+00]))
|
|
164
147
|
"""
|
|
165
|
-
_update_hook_version() # pylint:disable=protected-access
|
|
166
|
-
|
|
167
148
|
if self.hook_dict_ref is not None:
|
|
168
149
|
hook_dict = self.hook_dict_ref()
|
|
169
150
|
if hook_dict is not None and self.handle_id in hook_dict:
|
mindspore/common/np_dtype.py
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
# ============================================================================
|
|
17
17
|
"""Numpy data type for MindSpore."""
|
|
18
18
|
|
|
19
|
-
from mindspore._c_expression.np_dtypes import
|
|
20
|
-
if
|
|
19
|
+
from mindspore._c_expression.np_dtypes import np_version_valid
|
|
20
|
+
if np_version_valid(True):
|
|
21
21
|
from mindspore._c_expression.np_dtypes import bfloat16 # pylint: disable=unused-import
|
|
22
22
|
|
|
23
23
|
__all__ = []
|
|
24
|
-
if
|
|
24
|
+
if np_version_valid(False):
|
|
25
25
|
__all__.extend(["bfloat16"])
|
mindspore/common/parameter.py
CHANGED
|
@@ -33,7 +33,6 @@ from mindspore import context
|
|
|
33
33
|
from mindspore.common._utils import get_slice_num, get_slice_shape
|
|
34
34
|
from mindspore.common.initializer import initializer
|
|
35
35
|
from mindspore.common.tensor import Tensor, _TensorMeta
|
|
36
|
-
from mindspore.common.hook_handle import _update_hook_version
|
|
37
36
|
from mindspore import _checkparam as Validator
|
|
38
37
|
from mindspore._check_jit_forbidden_api import jit_forbidden_register
|
|
39
38
|
from mindspore._c_expression import TensorPy as Tensor_
|
|
@@ -72,6 +71,19 @@ def _is_parameter_generated(param_name):
|
|
|
72
71
|
# Global variable for parameter unique key.
|
|
73
72
|
_GLOBAL_PARAMETER_KEY = -1
|
|
74
73
|
|
|
74
|
+
# Global variable to mark the hook of parameter is updated
|
|
75
|
+
_parameter_hook_updated = True
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def set_parameter_hook_updated(value):
|
|
79
|
+
global _parameter_hook_updated
|
|
80
|
+
_parameter_hook_updated = value
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def parameter_hook_updated():
|
|
84
|
+
global _parameter_hook_updated
|
|
85
|
+
return _parameter_hook_updated
|
|
86
|
+
|
|
75
87
|
|
|
76
88
|
def _is_in_auto_parallel_mode():
|
|
77
89
|
"""Get parallel mode."""
|
|
@@ -80,7 +92,7 @@ def _is_in_auto_parallel_mode():
|
|
|
80
92
|
|
|
81
93
|
def _is_parallel_mode():
|
|
82
94
|
""" Whether is parallel mode """
|
|
83
|
-
if not _is_initialized():
|
|
95
|
+
if not _is_initialized() or context.get_context('mode') == context.PYNATIVE_MODE:
|
|
84
96
|
return False
|
|
85
97
|
if os.getenv("RUN_MODE") != "predict":
|
|
86
98
|
return False
|
|
@@ -418,6 +430,10 @@ class Parameter(Tensor_):
|
|
|
418
430
|
"1. context.set_ps_context(enable_ps=True) \n"
|
|
419
431
|
"2. export MS_ROLE environment variable \n"
|
|
420
432
|
"Please refer to the official website for detailed usage.")
|
|
433
|
+
|
|
434
|
+
if context.get_context("mode") == context.PYNATIVE_MODE:
|
|
435
|
+
raise RuntimeError("Parameter server training is not supported in pynative mode currently."
|
|
436
|
+
"Please switch to graph mode and retry.")
|
|
421
437
|
self.is_param_ps = True
|
|
422
438
|
self.init_in_server = init_in_server
|
|
423
439
|
self.param_info.init_in_server = init_in_server
|
|
@@ -1007,11 +1023,11 @@ class Parameter(Tensor_):
|
|
|
1007
1023
|
For details, please refer to :func:`mindspore.Tensor.register_hook`.
|
|
1008
1024
|
"""
|
|
1009
1025
|
handle = Tensor.register_hook(self, hook_fn)
|
|
1010
|
-
|
|
1026
|
+
set_parameter_hook_updated(True)
|
|
1011
1027
|
return handle
|
|
1012
1028
|
|
|
1013
1029
|
def _remove_hook(self):
|
|
1014
|
-
|
|
1030
|
+
set_parameter_hook_updated(True)
|
|
1015
1031
|
|
|
1016
1032
|
def _offload(self):
|
|
1017
1033
|
r"""
|
mindspore/common/recompute.py
CHANGED
|
@@ -18,6 +18,7 @@ from collections import OrderedDict
|
|
|
18
18
|
from types import MethodType
|
|
19
19
|
from mindspore import log as logger
|
|
20
20
|
from mindspore.nn.cell import Cell
|
|
21
|
+
from mindspore import context
|
|
21
22
|
from mindspore.common.tensor import Tensor
|
|
22
23
|
from mindspore import ops
|
|
23
24
|
from mindspore.ops.composite import GradOperation
|
|
@@ -26,7 +27,6 @@ from mindspore.common.api import _pynative_executor, _no_grad
|
|
|
26
27
|
from mindspore.common.generator import get_rng_state, set_rng_state
|
|
27
28
|
from mindspore.train.amp import AmpDecorator
|
|
28
29
|
from mindspore._c_expression.amp import get_curr_amp_strategy
|
|
29
|
-
from mindspore._check_jit_forbidden_api import jit_forbidden_register
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class _WrapCell(Cell):
|
|
@@ -211,12 +211,14 @@ def _detach_input(input_arg):
|
|
|
211
211
|
def _check_validation(block):
|
|
212
212
|
if not isinstance(block, Cell):
|
|
213
213
|
raise TypeError("Recompute function now only support block which inherited from Cell!")
|
|
214
|
+
if context.get_context("mode") != context.PYNATIVE_MODE:
|
|
215
|
+
raise AssertionError("Recompute function now only support pynative mode, you can use "
|
|
216
|
+
"Cell.recompute() in graph mode.")
|
|
214
217
|
if block.construct.__code__.co_name == "staging_specialize":
|
|
215
218
|
logger.warning('Block\'s construct method decorated by @jit that recompute '
|
|
216
219
|
'function will not come into effect.')
|
|
217
220
|
|
|
218
221
|
|
|
219
|
-
@jit_forbidden_register
|
|
220
222
|
def recompute(block, *args, **kwargs):
|
|
221
223
|
r"""
|
|
222
224
|
This function is used to reduce memory, when run block, rather than
|