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
|
@@ -21,7 +21,7 @@ except ImportError:
|
|
|
21
21
|
from .device import _is_supported
|
|
22
22
|
|
|
23
23
|
function_status = {'op_compile': False, 'aoe_tune_mode': False,
|
|
24
|
-
'aoe_job_type': False
|
|
24
|
+
'aoe_job_type': False}
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def op_compile(value):
|
|
@@ -121,37 +121,3 @@ def aoe_job_type(config):
|
|
|
121
121
|
f"For 'aoe_job_type', the config must be one of {aoe_cfgs}, but got {config}."
|
|
122
122
|
)
|
|
123
123
|
AscendOpTuningConf.get_instance().set_aoe_job_type(config)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def aclnn_cache(enable_global_cache=False, cache_queue_length=10000):
|
|
127
|
-
"""
|
|
128
|
-
Configure aclnn cache parameters.
|
|
129
|
-
|
|
130
|
-
Args:
|
|
131
|
-
enable_global_cache (bool): Set the calnn cache to global when GRAPH_MODE.
|
|
132
|
-
Default: ``False``.
|
|
133
|
-
cache_queue_length (int, optional): Set the cache queue length.
|
|
134
|
-
Default: ``10000``.
|
|
135
|
-
|
|
136
|
-
Examples:
|
|
137
|
-
>>> import mindspore as ms
|
|
138
|
-
>>> ms.device_context.ascend.op_tuning.aclnn_cache(True, 10000)
|
|
139
|
-
"""
|
|
140
|
-
if not function_status['aclnn_cache']:
|
|
141
|
-
function_status['aclnn_cache'] = True
|
|
142
|
-
if not _is_supported():
|
|
143
|
-
return
|
|
144
|
-
# Check the configuration environment whether valid
|
|
145
|
-
if AscendOpTuningConf.get_instance().is_aclnn_cache_configured():
|
|
146
|
-
raise RuntimeError("The 'aclnn_cache' can not be set repeatedly.")
|
|
147
|
-
cache_cfgs = [True, False]
|
|
148
|
-
if enable_global_cache not in cache_cfgs:
|
|
149
|
-
raise ValueError(
|
|
150
|
-
f"For 'aclnn_cache', the config must be one of {cache_cfgs}, but got {enable_global_cache}."
|
|
151
|
-
)
|
|
152
|
-
AscendOpTuningConf.get_instance().set_aclnn_global_cache(enable_global_cache)
|
|
153
|
-
if cache_queue_length < 0:
|
|
154
|
-
raise ValueError(
|
|
155
|
-
f"For 'aclnn_cache', the config must greater than 0, but got {enable_global_cache}."
|
|
156
|
-
)
|
|
157
|
-
AscendOpTuningConf.get_instance().set_cache_queue_length(cache_queue_length)
|
mindspore/dnnl.dll
CHANGED
|
Binary file
|
|
@@ -18,7 +18,6 @@ import os
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
from mindspore.common import Tensor, dtype
|
|
20
20
|
from mindspore.experimental.llm_boost.ascend_native.llm_boost import LLMBoost
|
|
21
|
-
from mindspore.experimental.llm_boost.register import LlmBoostRegister, LlmBoostType
|
|
22
21
|
|
|
23
22
|
def RoundUp(val: int, align: int) -> int:
|
|
24
23
|
if align == 0:
|
|
@@ -43,8 +42,6 @@ def ConvertTensor(nd_mat: np.ndarray, transpose: bool = True, nd2nz: bool = True
|
|
|
43
42
|
nz_mat = nz_mat.reshape(r, c)
|
|
44
43
|
return nz_mat
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
@LlmBoostRegister.register(LlmBoostType.ASCEND_NATIVE, "Llama")
|
|
48
45
|
class LlamaBoostAscendNative(LLMBoost):
|
|
49
46
|
r"""
|
|
50
47
|
Implements an Llama model in a single kernel.
|
mindspore/include/api/cell.h
CHANGED
|
@@ -31,9 +31,7 @@ using Output = InputAndOutput;
|
|
|
31
31
|
|
|
32
32
|
class MS_API CellBase {
|
|
33
33
|
public:
|
|
34
|
-
/// \brief Constructor of Cellbase.
|
|
35
34
|
CellBase() = default;
|
|
36
|
-
/// \brief Destructor of Cellbase.
|
|
37
35
|
virtual ~CellBase() = default;
|
|
38
36
|
/// \brief Construct using inputs.
|
|
39
37
|
///
|
|
@@ -65,21 +63,12 @@ class MS_API Cell : public CellBase {
|
|
|
65
63
|
class MS_API GraphCell final : public Cell<GraphCell> {
|
|
66
64
|
public:
|
|
67
65
|
class GraphImpl;
|
|
68
|
-
|
|
66
|
+
|
|
69
67
|
GraphCell() = default;
|
|
70
|
-
/// \brief Destructor of GraphCell.
|
|
71
68
|
~GraphCell() override = default;
|
|
72
|
-
|
|
73
|
-
///
|
|
74
|
-
/// \param[in] graph Graph to construct.
|
|
69
|
+
|
|
75
70
|
explicit GraphCell(const Graph &graph);
|
|
76
|
-
/// \brief Constructor of GraphCell.
|
|
77
|
-
///
|
|
78
|
-
/// \param[in] graph Graph to construct.
|
|
79
71
|
explicit GraphCell(Graph &&graph);
|
|
80
|
-
/// \brief Constructor of GraphCell.
|
|
81
|
-
///
|
|
82
|
-
/// \param[in] graph Graph to construct.
|
|
83
72
|
explicit GraphCell(const std::shared_ptr<Graph> &graph);
|
|
84
73
|
/// \brief Set a context.
|
|
85
74
|
///
|
|
@@ -120,25 +109,12 @@ class MS_API GraphCell final : public Cell<GraphCell> {
|
|
|
120
109
|
|
|
121
110
|
class MS_API InputAndOutput {
|
|
122
111
|
public:
|
|
123
|
-
/// \brief Constructor of InputAndOutput.
|
|
124
112
|
InputAndOutput();
|
|
125
|
-
/// \brief Destructor of InputAndOutput.
|
|
126
113
|
~InputAndOutput() = default;
|
|
127
|
-
|
|
128
|
-
///
|
|
129
|
-
/// \param[in] cell The cellbase.
|
|
130
|
-
///
|
|
131
|
-
/// \param[in] prev The previous inputs/outputs.
|
|
132
|
-
///
|
|
133
|
-
/// \param[in] index Index of inputs/outputs.
|
|
114
|
+
|
|
134
115
|
InputAndOutput(const std::shared_ptr<CellBase> &cell, const std::vector<InputAndOutput> &prev, int32_t index);
|
|
135
|
-
|
|
136
|
-
///
|
|
137
|
-
/// \return index Index of inputs/outputs.
|
|
116
|
+
|
|
138
117
|
int32_t GetIndex() const { return index_; }
|
|
139
|
-
/// \brief Set index.
|
|
140
|
-
///
|
|
141
|
-
/// \param[in] index Index to be set.
|
|
142
118
|
void SetIndex(int32_t index) { index_ = index; }
|
|
143
119
|
|
|
144
120
|
private:
|
mindspore/include/api/cfg.h
CHANGED
|
@@ -28,50 +28,35 @@ namespace mindspore {
|
|
|
28
28
|
constexpr int iter_th = 1000;
|
|
29
29
|
class MS_API MixPrecisionCfg {
|
|
30
30
|
public:
|
|
31
|
-
/// \brief Constructor of mix precision training config.
|
|
32
31
|
MixPrecisionCfg() {
|
|
33
32
|
this->dynamic_loss_scale_ = false;
|
|
34
33
|
this->loss_scale_ = 128.0f;
|
|
35
34
|
this->keep_batchnorm_fp32_ = true;
|
|
36
35
|
this->num_of_not_nan_iter_th_ = iter_th;
|
|
37
36
|
}
|
|
38
|
-
/// \brief Constructor of mix precision training config.
|
|
39
|
-
///
|
|
40
|
-
/// \param[in] rhs The config of mix precision.
|
|
41
37
|
MixPrecisionCfg(const MixPrecisionCfg &rhs) {
|
|
42
38
|
this->dynamic_loss_scale_ = rhs.dynamic_loss_scale_;
|
|
43
39
|
this->loss_scale_ = rhs.loss_scale_;
|
|
44
40
|
this->keep_batchnorm_fp32_ = rhs.keep_batchnorm_fp32_;
|
|
45
41
|
this->num_of_not_nan_iter_th_ = rhs.num_of_not_nan_iter_th_;
|
|
46
42
|
}
|
|
47
|
-
/// \brief Destructor of mix precision config.
|
|
48
43
|
~MixPrecisionCfg() = default;
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
bool keep_batchnorm_fp32_ = true;
|
|
56
|
-
/// \brief A threshold for modifying loss scale when dynamic loss scale is enabled.
|
|
57
|
-
uint32_t num_of_not_nan_iter_th_;
|
|
58
|
-
/// \brief Is mix precision model export from mindspore.
|
|
59
|
-
bool is_raw_mix_precision_ = false;
|
|
45
|
+
bool dynamic_loss_scale_ = false; /**< Enable/disable dynamic loss scale during mix precision training */
|
|
46
|
+
float loss_scale_; /**< Initial loss scale factor */
|
|
47
|
+
bool keep_batchnorm_fp32_ = true; /**< Keep batch norm in FP32 while training */
|
|
48
|
+
uint32_t num_of_not_nan_iter_th_; /**< a threshold for modifying loss scale when dynamic loss scale is enabled */
|
|
49
|
+
bool is_raw_mix_precision_ = false; /**< Is mix precision model export from mindspore */
|
|
60
50
|
};
|
|
61
51
|
|
|
62
52
|
class MS_API TrainCfg {
|
|
63
53
|
public:
|
|
64
|
-
/// \brief Constructor of training config.
|
|
65
54
|
TrainCfg() = default;
|
|
66
|
-
/// \brief Constructor of training config.
|
|
67
|
-
///
|
|
68
|
-
/// \param[in] rhs The training config.
|
|
69
55
|
TrainCfg(const TrainCfg &rhs) {
|
|
70
56
|
this->loss_name_ = rhs.loss_name_;
|
|
71
57
|
this->mix_precision_cfg_ = rhs.mix_precision_cfg_;
|
|
72
58
|
this->accumulate_gradients_ = rhs.accumulate_gradients_;
|
|
73
59
|
}
|
|
74
|
-
/// \brief Destructor of training config.
|
|
75
60
|
~TrainCfg() = default;
|
|
76
61
|
|
|
77
62
|
/// \brief obtain part of the name that identify a loss kernel.
|
|
@@ -82,11 +67,9 @@ class MS_API TrainCfg {
|
|
|
82
67
|
///
|
|
83
68
|
/// \param[in] loss_name define part of the name that identify a loss kernel.
|
|
84
69
|
inline void SetLossName(const std::vector<std::string> &loss_name);
|
|
85
|
-
|
|
70
|
+
|
|
86
71
|
OptimizationLevel optimization_level_ = kO0;
|
|
87
|
-
|
|
88
|
-
MixPrecisionCfg mix_precision_cfg_;
|
|
89
|
-
/// \brief If accumulate gradients is used.
|
|
72
|
+
MixPrecisionCfg mix_precision_cfg_; /**< Mix precision configuration */
|
|
90
73
|
bool accumulate_gradients_ = false;
|
|
91
74
|
|
|
92
75
|
private:
|
mindspore/include/api/context.h
CHANGED
mindspore/include/api/delegate.h
CHANGED
|
@@ -129,6 +129,7 @@ class Delegate : public IDelegate<LiteDelegateGraph, kernel::Kernel, kernel::Ker
|
|
|
129
129
|
///
|
|
130
130
|
/// \return Status. If Status is kLiteNotSupport, the program will return to the MindSpore Lite inner inference.
|
|
131
131
|
virtual Status Init() = 0;
|
|
132
|
+
|
|
132
133
|
/// \brief Create kernel.
|
|
133
134
|
///
|
|
134
135
|
/// \param[in] node The kernel to be created.
|
|
@@ -138,6 +139,7 @@ class Delegate : public IDelegate<LiteDelegateGraph, kernel::Kernel, kernel::Ker
|
|
|
138
139
|
// return node as kernel since they are same one.
|
|
139
140
|
return node;
|
|
140
141
|
}
|
|
142
|
+
|
|
141
143
|
/// \brief Check if the node is delegate node.
|
|
142
144
|
///
|
|
143
145
|
/// \param[in] node The kernel to verify.
|
|
@@ -28,11 +28,6 @@
|
|
|
28
28
|
|
|
29
29
|
namespace mindspore {
|
|
30
30
|
using VecChar = std::vector<char>;
|
|
31
|
-
/// \brief Transform string to char.
|
|
32
|
-
///
|
|
33
|
-
/// \param[in] s Define the string to transform.
|
|
34
|
-
///
|
|
35
|
-
/// \return Vector of chars.
|
|
36
31
|
inline std::vector<char> StringToChar(const std::string &s) {
|
|
37
32
|
if (s.empty()) {
|
|
38
33
|
const auto empty = std::vector<char>();
|
|
@@ -40,11 +35,7 @@ inline std::vector<char> StringToChar(const std::string &s) {
|
|
|
40
35
|
}
|
|
41
36
|
return std::vector<char>(s.begin(), s.end());
|
|
42
37
|
}
|
|
43
|
-
|
|
44
|
-
///
|
|
45
|
-
/// \param[in] c Define the chars to transform.
|
|
46
|
-
///
|
|
47
|
-
/// \return String.
|
|
38
|
+
|
|
48
39
|
inline std::string CharToString(const std::vector<char> &c) {
|
|
49
40
|
if (c.empty()) {
|
|
50
41
|
const auto empty = "";
|
|
@@ -52,71 +43,43 @@ inline std::string CharToString(const std::vector<char> &c) {
|
|
|
52
43
|
}
|
|
53
44
|
return std::string(c.begin(), c.end());
|
|
54
45
|
}
|
|
55
|
-
|
|
56
|
-
///
|
|
57
|
-
/// \param[in] s Pair of strings to transform.
|
|
58
|
-
///
|
|
59
|
-
/// \return Pair of chars.
|
|
46
|
+
|
|
60
47
|
inline std::pair<std::vector<char>, int32_t> PairStringToChar(const std::pair<std::string, int32_t> &s) {
|
|
61
48
|
return std::pair<std::vector<char>, int32_t>(std::vector<char>(s.first.begin(), s.first.end()), s.second);
|
|
62
49
|
}
|
|
63
|
-
|
|
64
|
-
///
|
|
65
|
-
/// \param[in] c Pair of chars to transform.
|
|
66
|
-
///
|
|
67
|
-
/// \return Pair of strings.
|
|
50
|
+
|
|
68
51
|
inline std::pair<std::string, int32_t> PairCharToString(const std::pair<std::vector<char>, int32_t> &c) {
|
|
69
52
|
return std::pair<std::string, int32_t>(std::string(c.first.begin(), c.first.end()), c.second);
|
|
70
53
|
}
|
|
71
|
-
|
|
72
|
-
///
|
|
73
|
-
/// \param[in] s Vector of strings.
|
|
74
|
-
///
|
|
75
|
-
/// \return Vector of vector of chars.
|
|
54
|
+
|
|
76
55
|
inline std::vector<std::vector<char>> VectorStringToChar(const std::vector<std::string> &s) {
|
|
77
56
|
std::vector<std::vector<char>> ret;
|
|
78
57
|
std::transform(s.begin(), s.end(), std::back_inserter(ret),
|
|
79
58
|
[](auto str) { return std::vector<char>(str.begin(), str.end()); });
|
|
80
59
|
return ret;
|
|
81
60
|
}
|
|
82
|
-
|
|
83
|
-
///
|
|
84
|
-
/// \param[in] c Vector of vector ofof schars.
|
|
85
|
-
///
|
|
86
|
-
/// \return Vector of strings.
|
|
61
|
+
|
|
87
62
|
inline std::vector<std::string> VectorCharToString(const std::vector<std::vector<char>> &c) {
|
|
88
63
|
std::vector<std::string> ret;
|
|
89
64
|
std::transform(c.begin(), c.end(), std::back_inserter(ret),
|
|
90
65
|
[](auto ch) { return std::string(ch.begin(), ch.end()); });
|
|
91
66
|
return ret;
|
|
92
67
|
}
|
|
93
|
-
|
|
94
|
-
///
|
|
95
|
-
/// \param[in] s Set of strings.
|
|
96
|
-
///
|
|
97
|
-
/// \return Set of vector of chars.
|
|
68
|
+
|
|
98
69
|
inline std::set<std::vector<char>> SetStringToChar(const std::set<std::string> &s) {
|
|
99
70
|
std::set<std::vector<char>> ret;
|
|
100
71
|
std::transform(s.begin(), s.end(), std::inserter(ret, ret.begin()),
|
|
101
72
|
[](auto str) { return std::vector<char>(str.begin(), str.end()); });
|
|
102
73
|
return ret;
|
|
103
74
|
}
|
|
104
|
-
|
|
105
|
-
///
|
|
106
|
-
/// \param[in] c Set of chars.
|
|
107
|
-
///
|
|
108
|
-
/// \return Set of strings.
|
|
75
|
+
|
|
109
76
|
inline std::set<std::string> SetCharToString(const std::set<std::vector<char>> &c) {
|
|
110
77
|
std::set<std::string> ret;
|
|
111
78
|
std::transform(c.begin(), c.end(), std::inserter(ret, ret.begin()),
|
|
112
79
|
[](auto ch) { return std::string(ch.begin(), ch.end()); });
|
|
113
80
|
return ret;
|
|
114
81
|
}
|
|
115
|
-
|
|
116
|
-
///
|
|
117
|
-
/// \param[in] s Map of strings.
|
|
118
|
-
///
|
|
119
|
-
/// \return Map of vector of chars.
|
|
82
|
+
|
|
120
83
|
template <class T>
|
|
121
84
|
inline std::map<std::vector<char>, T> MapStringToChar(const std::map<std::string, T> &s) {
|
|
122
85
|
std::map<std::vector<char>, T> ret;
|
|
@@ -125,11 +88,7 @@ inline std::map<std::vector<char>, T> MapStringToChar(const std::map<std::string
|
|
|
125
88
|
});
|
|
126
89
|
return ret;
|
|
127
90
|
}
|
|
128
|
-
|
|
129
|
-
///
|
|
130
|
-
/// \param[in] c Map of vector of chars.
|
|
131
|
-
///
|
|
132
|
-
/// \return Map of strings.
|
|
91
|
+
|
|
133
92
|
template <class T>
|
|
134
93
|
inline std::map<std::string, T> MapCharToString(const std::map<std::vector<char>, T> &c) {
|
|
135
94
|
std::map<std::string, T> ret;
|
|
@@ -138,11 +97,7 @@ inline std::map<std::string, T> MapCharToString(const std::map<std::vector<char>
|
|
|
138
97
|
});
|
|
139
98
|
return ret;
|
|
140
99
|
}
|
|
141
|
-
|
|
142
|
-
///
|
|
143
|
-
/// \param[in] s Unordered_map of strings.
|
|
144
|
-
///
|
|
145
|
-
/// \return Map of vector of chars.
|
|
100
|
+
|
|
146
101
|
inline std::map<std::vector<char>, std::vector<char>> UnorderedMapStringToChar(
|
|
147
102
|
const std::unordered_map<std::string, std::string> &s) {
|
|
148
103
|
std::map<std::vector<char>, std::vector<char>> ret;
|
|
@@ -152,11 +107,7 @@ inline std::map<std::vector<char>, std::vector<char>> UnorderedMapStringToChar(
|
|
|
152
107
|
});
|
|
153
108
|
return ret;
|
|
154
109
|
}
|
|
155
|
-
|
|
156
|
-
///
|
|
157
|
-
/// \param[in] c Map of vector of chars.
|
|
158
|
-
///
|
|
159
|
-
/// \return Unordered map of strings.
|
|
110
|
+
|
|
160
111
|
inline std::unordered_map<std::string, std::string> UnorderedMapCharToString(
|
|
161
112
|
const std::map<std::vector<char>, std::vector<char>> &c) {
|
|
162
113
|
std::unordered_map<std::string, std::string> ret;
|
|
@@ -166,11 +117,7 @@ inline std::unordered_map<std::string, std::string> UnorderedMapCharToString(
|
|
|
166
117
|
});
|
|
167
118
|
return ret;
|
|
168
119
|
}
|
|
169
|
-
|
|
170
|
-
///
|
|
171
|
-
/// \param[in] s Map of vector of strings.
|
|
172
|
-
///
|
|
173
|
-
/// \return Map of vector of chars.
|
|
120
|
+
|
|
174
121
|
inline std::map<std::vector<char>, std::vector<char>> MapStringToVectorChar(
|
|
175
122
|
const std::map<std::string, std::string> &s) {
|
|
176
123
|
std::map<std::vector<char>, std::vector<char>> ret;
|
|
@@ -180,11 +127,7 @@ inline std::map<std::vector<char>, std::vector<char>> MapStringToVectorChar(
|
|
|
180
127
|
});
|
|
181
128
|
return ret;
|
|
182
129
|
}
|
|
183
|
-
|
|
184
|
-
///
|
|
185
|
-
/// \param[in] c Map of vector of chars.
|
|
186
|
-
///
|
|
187
|
-
/// \return Map of strings.
|
|
130
|
+
|
|
188
131
|
inline std::map<std::string, std::string> MapVectorCharToString(
|
|
189
132
|
const std::map<std::vector<char>, std::vector<char>> &c) {
|
|
190
133
|
std::map<std::string, std::string> ret;
|
|
@@ -194,11 +137,7 @@ inline std::map<std::string, std::string> MapVectorCharToString(
|
|
|
194
137
|
});
|
|
195
138
|
return ret;
|
|
196
139
|
}
|
|
197
|
-
|
|
198
|
-
///
|
|
199
|
-
/// \param[in] s Vector of pair of strings.
|
|
200
|
-
///
|
|
201
|
-
/// \return Vector of pair of vector of chars.
|
|
140
|
+
|
|
202
141
|
inline std::vector<std::pair<std::vector<char>, std::vector<int32_t>>> ClassIndexStringToChar(
|
|
203
142
|
const std::vector<std::pair<std::string, std::vector<int32_t>>> &s) {
|
|
204
143
|
std::vector<std::pair<std::vector<char>, std::vector<int32_t>>> ret;
|
|
@@ -208,11 +147,7 @@ inline std::vector<std::pair<std::vector<char>, std::vector<int32_t>>> ClassInde
|
|
|
208
147
|
});
|
|
209
148
|
return ret;
|
|
210
149
|
}
|
|
211
|
-
|
|
212
|
-
///
|
|
213
|
-
/// \param[in] c Vector of pair of schar.
|
|
214
|
-
///
|
|
215
|
-
/// \return Vector of pair of vector of strings.
|
|
150
|
+
|
|
216
151
|
inline std::vector<std::pair<std::string, std::vector<int32_t>>> ClassIndexCharToString(
|
|
217
152
|
const std::vector<std::pair<std::vector<char>, std::vector<int32_t>>> &c) {
|
|
218
153
|
std::vector<std::pair<std::string, std::vector<int32_t>>> ret;
|
|
@@ -221,11 +156,7 @@ inline std::vector<std::pair<std::string, std::vector<int32_t>>> ClassIndexCharT
|
|
|
221
156
|
});
|
|
222
157
|
return ret;
|
|
223
158
|
}
|
|
224
|
-
|
|
225
|
-
///
|
|
226
|
-
/// \param[in] s Vector of pair of strings.
|
|
227
|
-
///
|
|
228
|
-
/// \return Vector of pair of vector of chars.
|
|
159
|
+
|
|
229
160
|
inline std::vector<std::pair<std::vector<char>, int64_t>> PairStringInt64ToPairCharInt64(
|
|
230
161
|
const std::vector<std::pair<std::string, int64_t>> &s) {
|
|
231
162
|
std::vector<std::pair<std::vector<char>, int64_t>> ret;
|
|
@@ -234,11 +165,7 @@ inline std::vector<std::pair<std::vector<char>, int64_t>> PairStringInt64ToPairC
|
|
|
234
165
|
});
|
|
235
166
|
return ret;
|
|
236
167
|
}
|
|
237
|
-
|
|
238
|
-
///
|
|
239
|
-
/// \param[in] c Map of Vector of chars.
|
|
240
|
-
///
|
|
241
|
-
/// \param[in] s Unordered map of strings, which will be changed after the function.
|
|
168
|
+
|
|
242
169
|
template <class T>
|
|
243
170
|
inline void TensorMapCharToString(const std::map<std::vector<char>, T> *c, std::unordered_map<std::string, T> *s) {
|
|
244
171
|
if (c == nullptr || s == nullptr) {
|
|
@@ -250,11 +177,7 @@ inline void TensorMapCharToString(const std::map<std::vector<char>, T> *c, std::
|
|
|
250
177
|
s->insert(std::pair<std::string, T>(key, val));
|
|
251
178
|
}
|
|
252
179
|
}
|
|
253
|
-
|
|
254
|
-
///
|
|
255
|
-
/// \param[in] c Map of map of chars.
|
|
256
|
-
///
|
|
257
|
-
/// \return Map of strings.
|
|
180
|
+
|
|
258
181
|
inline std::map<std::string, std::map<std::string, std::string>> MapMapCharToString(
|
|
259
182
|
const std::map<std::vector<char>, std::map<std::vector<char>, std::vector<char>>> &c) {
|
|
260
183
|
std::map<std::string, std::map<std::string, std::string>> ret;
|
|
@@ -268,11 +191,7 @@ inline std::map<std::string, std::map<std::string, std::string>> MapMapCharToStr
|
|
|
268
191
|
}
|
|
269
192
|
return ret;
|
|
270
193
|
}
|
|
271
|
-
|
|
272
|
-
///
|
|
273
|
-
/// \param[in] s Map of map of strings.
|
|
274
|
-
///
|
|
275
|
-
/// \return Map of chars.
|
|
194
|
+
|
|
276
195
|
inline std::map<std::vector<char>, std::map<std::vector<char>, std::vector<char>>> MapMapStringToChar(
|
|
277
196
|
const std::map<std::string, std::map<std::string, std::string>> &s) {
|
|
278
197
|
std::map<std::vector<char>, std::map<std::vector<char>, std::vector<char>>> ret;
|
mindspore/include/api/graph.h
CHANGED
|
@@ -27,27 +27,14 @@ namespace mindspore {
|
|
|
27
27
|
class MS_API Graph {
|
|
28
28
|
public:
|
|
29
29
|
class GraphData;
|
|
30
|
-
/// \brief Constructor of graph.
|
|
31
30
|
Graph();
|
|
32
|
-
/// \brief Constructor of graph.
|
|
33
|
-
///
|
|
34
|
-
/// \param[in] graph_data define the graph_data of graph.
|
|
35
31
|
explicit Graph(const std::shared_ptr<GraphData> &graph_data);
|
|
36
|
-
/// \brief Constructor of graph.
|
|
37
|
-
///
|
|
38
|
-
/// \param[in] graph_data define the graph_data of graph.
|
|
39
32
|
explicit Graph(std::shared_ptr<GraphData> &&graph_data);
|
|
40
|
-
/// \brief Constructor of Kernel.
|
|
41
33
|
explicit Graph(std::nullptr_t);
|
|
42
|
-
/// \brief Destructor of graph.
|
|
43
34
|
~Graph();
|
|
44
|
-
|
|
45
|
-
///
|
|
46
|
-
/// \return Model type.
|
|
35
|
+
|
|
47
36
|
enum ModelType ModelType() const;
|
|
48
|
-
/// \brief Operator equal.
|
|
49
37
|
bool operator==(std::nullptr_t) const;
|
|
50
|
-
/// \brief Operator not equal.
|
|
51
38
|
bool operator!=(std::nullptr_t) const;
|
|
52
39
|
|
|
53
40
|
private:
|
mindspore/include/api/kernel.h
CHANGED
|
@@ -28,35 +28,22 @@
|
|
|
28
28
|
namespace mindspore::kernel {
|
|
29
29
|
class MS_API Kernel : public IKernel<schema::Primitive> {
|
|
30
30
|
public:
|
|
31
|
-
/// \brief Constructor of Kernel.
|
|
32
31
|
Kernel() = default;
|
|
33
|
-
/// \brief Constructor of Kernel.
|
|
34
|
-
///
|
|
35
|
-
/// \param[in] inputs Input tensors.
|
|
36
|
-
///
|
|
37
|
-
/// \param[in] outputs Output tensors.
|
|
38
|
-
///
|
|
39
|
-
/// \param[in] primitive The primitive of kernel.
|
|
40
|
-
///
|
|
41
|
-
/// \param[in] context The context created.
|
|
42
32
|
Kernel(const std::vector<mindspore::MSTensor> &inputs, const std::vector<mindspore::MSTensor> &outputs,
|
|
43
33
|
const schema::Primitive *primitive, const mindspore::Context *ctx)
|
|
44
34
|
: IKernel<schema::Primitive>(inputs, outputs, primitive, ctx) {
|
|
45
35
|
Initialize();
|
|
46
36
|
}
|
|
47
|
-
/// \brief Destructor of Kernel.
|
|
48
37
|
virtual ~Kernel() = default;
|
|
49
|
-
|
|
50
|
-
///
|
|
51
|
-
/// \return status.
|
|
38
|
+
|
|
52
39
|
int InferShape() override;
|
|
53
40
|
/// \brief obtain kernel's type.
|
|
54
41
|
///
|
|
55
42
|
/// \return kernel's type.
|
|
56
43
|
virtual schema::PrimitiveType type() const { return type_; }
|
|
57
|
-
/// \brief
|
|
44
|
+
/// \brief obtain kernel's quant type.
|
|
58
45
|
///
|
|
59
|
-
/// \return
|
|
46
|
+
/// \return kernel's quant type.
|
|
60
47
|
virtual schema::QuantType quant_type() const { return quant_type_; }
|
|
61
48
|
/// \brief obtain the primitive of kernel generated by flatbuffers.
|
|
62
49
|
protected:
|
|
@@ -28,7 +28,6 @@ namespace kernel {
|
|
|
28
28
|
/// \brief The Kernel class is used to define a MindSpore Kernel.
|
|
29
29
|
class MS_API MSKernel {
|
|
30
30
|
public:
|
|
31
|
-
/// \brief Constructor of MSKernel.
|
|
32
31
|
MSKernel() = default;
|
|
33
32
|
/// \brief Constructor.
|
|
34
33
|
///
|
|
@@ -131,17 +130,12 @@ class MS_API MSKernel {
|
|
|
131
130
|
/// \param[in] key define the kernel's attribute key.
|
|
132
131
|
/// \param[in] value define the kernel's attribute value.
|
|
133
132
|
void SetAttr(const std::string &key, const std::string &value) { attrs_[key] = value; }
|
|
134
|
-
|
|
133
|
+
|
|
135
134
|
std::string name_;
|
|
136
|
-
/// \brief kernel's context.
|
|
137
135
|
const mindspore::Context *context_ = nullptr;
|
|
138
|
-
/// \brief kernel's inputs.
|
|
139
136
|
std::vector<mindspore::MSTensor> inputs_;
|
|
140
|
-
/// \brief kernel's outputs.
|
|
141
137
|
std::vector<mindspore::MSTensor> outputs_;
|
|
142
|
-
/// \brief kernel's attrs.
|
|
143
138
|
std::map<std::string, std::string> attrs_;
|
|
144
|
-
/// \brief kernel's config.
|
|
145
139
|
const std::map<std::string, std::map<std::string, std::string>> *config_ = nullptr;
|
|
146
140
|
};
|
|
147
141
|
|
|
@@ -149,7 +143,6 @@ class MS_API MSKernel {
|
|
|
149
143
|
template <typename Primitive>
|
|
150
144
|
class MS_API IKernel : public MSKernel {
|
|
151
145
|
public:
|
|
152
|
-
/// \brief Constructor of IKernel.
|
|
153
146
|
IKernel() = default;
|
|
154
147
|
/// \brief Constructor.
|
|
155
148
|
///
|
|
@@ -168,7 +161,6 @@ class MS_API IKernel : public MSKernel {
|
|
|
168
161
|
const Primitive *primitive() const { return this->primitive_; }
|
|
169
162
|
|
|
170
163
|
protected:
|
|
171
|
-
/// \brief kernel's primitive, which is deserialized from flatbuffers.
|
|
172
164
|
const Primitive *primitive_ = nullptr;
|
|
173
165
|
};
|
|
174
166
|
} // namespace kernel
|
|
@@ -25,19 +25,10 @@ constexpr int METRICS_MULTILABEL = 1;
|
|
|
25
25
|
|
|
26
26
|
class MS_API AccuracyMetrics : public Metrics {
|
|
27
27
|
public:
|
|
28
|
-
/// \brief Constructor of AccuracyMetrics.
|
|
29
|
-
///
|
|
30
|
-
/// \param[in] accuracy_metrics The metrics of accuracy.
|
|
31
|
-
/// \param[in] input_indexes The indexes of inputs.
|
|
32
|
-
/// \param[in] output_indexes The indexes of outputs.
|
|
33
|
-
|
|
34
28
|
explicit AccuracyMetrics(int accuracy_metrics = METRICS_CLASSIFICATION, const std::vector<int> &input_indexes = {1},
|
|
35
29
|
const std::vector<int> &output_indexes = {0});
|
|
36
|
-
/// \brief Destructor of AccuracyMetrics.
|
|
37
30
|
virtual ~AccuracyMetrics();
|
|
38
|
-
/// \brief Clear the accuracy metrics.
|
|
39
31
|
void Clear() override;
|
|
40
|
-
/// \brief Eval function.
|
|
41
32
|
float Eval() override;
|
|
42
33
|
};
|
|
43
34
|
|
mindspore/include/api/model.h
CHANGED
|
@@ -40,9 +40,7 @@ class Dataset;
|
|
|
40
40
|
/// \brief The Model class is used to define a MindSpore model, facilitating computational graph management.
|
|
41
41
|
class MS_API Model {
|
|
42
42
|
public:
|
|
43
|
-
/// \brief Constructor of Model.
|
|
44
43
|
Model();
|
|
45
|
-
/// \brief Destructor of Model.
|
|
46
44
|
~Model();
|
|
47
45
|
|
|
48
46
|
/// \brief Build a model from model buffer so that it can run on a device.
|
|
@@ -363,9 +361,6 @@ class MS_API Model {
|
|
|
363
361
|
/// \return Status of operation.
|
|
364
362
|
Status Evaluate(std::shared_ptr<dataset::Dataset> ds, std::vector<TrainCallBack *> cbs);
|
|
365
363
|
|
|
366
|
-
/// \brief Performs the implication.
|
|
367
|
-
///
|
|
368
|
-
/// \return the implication of the model.
|
|
369
364
|
const std::shared_ptr<ModelImpl> impl() const { return impl_; }
|
|
370
365
|
|
|
371
366
|
/// \brief Get model info by key
|
|
@@ -374,6 +369,7 @@ class MS_API Model {
|
|
|
374
369
|
///
|
|
375
370
|
/// \return The value of the model info associated with the given key.
|
|
376
371
|
inline std::string GetModelInfo(const std::string &key);
|
|
372
|
+
|
|
377
373
|
/// \brief Finish the model. (Only used for mindspore_lite's ascend backend.)
|
|
378
374
|
///
|
|
379
375
|
/// \return Status of the operation.
|
|
@@ -41,11 +41,7 @@ enum class ModelGroupFlag : int {
|
|
|
41
41
|
|
|
42
42
|
class MS_API ModelGroup {
|
|
43
43
|
public:
|
|
44
|
-
/// \brief Constructor of ModelGroup.
|
|
45
|
-
///
|
|
46
|
-
/// \param[in] flags The flags of model group.
|
|
47
44
|
explicit ModelGroup(ModelGroupFlag flags = ModelGroupFlag::kShareWorkspace);
|
|
48
|
-
/// \brief Destructor of ModelGroup.
|
|
49
45
|
~ModelGroup() = default;
|
|
50
46
|
|
|
51
47
|
/// \brief Add models that require shared workspace memory.
|
|
@@ -28,9 +28,7 @@ namespace mindspore {
|
|
|
28
28
|
class MS_API RunnerConfig {
|
|
29
29
|
public:
|
|
30
30
|
struct Data;
|
|
31
|
-
/// \brief Constructor of RunnerConfig.
|
|
32
31
|
RunnerConfig();
|
|
33
|
-
/// \brief Destructor of RunnerConfig.
|
|
34
32
|
~RunnerConfig();
|
|
35
33
|
|
|
36
34
|
/// \brief Set the number of workers at runtime. Only valid for ModelParallelRunner.
|