mindspore 2.7.0__cp310-cp310-win_amd64.whl → 2.7.1__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 +4 -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/_extends/parse/compile_config.py +24 -1
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +6 -2
- mindspore/_extends/parse/resources.py +1 -1
- mindspore/_extends/parse/standard_method.py +8 -1
- mindspore/_extends/parse/trope.py +2 -1
- mindspore/_extends/pijit/pijit_func_white_list.py +7 -22
- 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/base.py +29 -2
- mindspore/common/_decorator.py +3 -2
- mindspore/common/_grad_function.py +3 -1
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +275 -64
- mindspore/common/_utils.py +0 -44
- mindspore/common/api.py +285 -35
- mindspore/common/dump.py +7 -108
- mindspore/common/dynamic_shape/auto_dynamic_shape.py +1 -3
- mindspore/common/hook_handle.py +60 -0
- mindspore/common/jit_config.py +5 -1
- mindspore/common/jit_trace.py +27 -12
- mindspore/common/lazy_inline.py +5 -3
- mindspore/common/parameter.py +13 -107
- mindspore/common/recompute.py +4 -11
- mindspore/common/tensor.py +16 -169
- mindspore/communication/_comm_helper.py +11 -1
- mindspore/communication/comm_func.py +138 -4
- mindspore/communication/management.py +85 -1
- mindspore/config/op_info.config +0 -15
- mindspore/context.py +5 -85
- mindspore/dataset/engine/datasets.py +8 -4
- mindspore/dataset/engine/datasets_vision.py +1 -1
- mindspore/dataset/engine/validators.py +1 -15
- mindspore/dnnl.dll +0 -0
- mindspore/{experimental/llm_boost/ascend_native → graph}/__init__.py +7 -7
- mindspore/graph/custom_pass.py +55 -0
- mindspore/include/dataset/execute.h +2 -2
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/__init__.py +3 -3
- mindspore/mindrecord/common/exceptions.py +1 -0
- mindspore/mindrecord/config.py +1 -1
- mindspore/{parallel/mpi → mindrecord/core}/__init__.py +4 -1
- mindspore/mindrecord/{shardheader.py → core/shardheader.py} +2 -1
- mindspore/mindrecord/{shardindexgenerator.py → core/shardindexgenerator.py} +1 -1
- mindspore/mindrecord/{shardreader.py → core/shardreader.py} +2 -1
- mindspore/mindrecord/{shardsegment.py → core/shardsegment.py} +2 -2
- mindspore/mindrecord/{shardutils.py → core/shardutils.py} +1 -1
- mindspore/mindrecord/{shardwriter.py → core/shardwriter.py} +1 -1
- mindspore/mindrecord/filereader.py +4 -4
- mindspore/mindrecord/filewriter.py +5 -5
- mindspore/mindrecord/mindpage.py +2 -2
- mindspore/mindrecord/tools/cifar10.py +1 -1
- mindspore/mindrecord/tools/cifar100.py +1 -1
- mindspore/mindrecord/tools/cifar100_to_mr.py +1 -1
- mindspore/mindrecord/tools/cifar10_to_mr.py +1 -1
- mindspore/mindrecord/tools/csv_to_mr.py +1 -1
- mindspore/mindrecord/tools/imagenet_to_mr.py +1 -1
- mindspore/mindrecord/tools/mnist_to_mr.py +1 -1
- mindspore/mindrecord/tools/tfrecord_to_mr.py +1 -1
- mindspore/mindspore_backend_common.dll +0 -0
- mindspore/mindspore_backend_manager.dll +0 -0
- mindspore/mindspore_cluster.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_cpu.dll +0 -0
- mindspore/mindspore_dump.dll +0 -0
- mindspore/mindspore_frontend.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_hardware_abstract.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 → mindspore_ops_cpu.dll} +0 -0
- mindspore/mindspore_profiler.dll +0 -0
- mindspore/mindspore_pyboost.dll +0 -0
- mindspore/mindspore_pynative.dll +0 -0
- mindspore/mindspore_runtime_pipeline.dll +0 -0
- mindspore/mindspore_runtime_utils.dll +0 -0
- mindspore/mindspore_tools.dll +0 -0
- mindspore/mint/__init__.py +15 -10
- mindspore/mint/distributed/distributed.py +182 -62
- mindspore/mint/nn/__init__.py +2 -16
- mindspore/mint/nn/functional.py +4 -110
- mindspore/mint/nn/layer/__init__.py +0 -2
- mindspore/mint/nn/layer/activation.py +0 -6
- mindspore/mint/nn/layer/basic.py +0 -47
- mindspore/mint/nn/layer/conv.py +4 -4
- mindspore/mint/nn/layer/normalization.py +8 -13
- mindspore/mint/nn/layer/pooling.py +0 -4
- mindspore/nn/__init__.py +1 -3
- mindspore/nn/cell.py +16 -66
- mindspore/nn/layer/basic.py +49 -1
- mindspore/nn/layer/container.py +16 -0
- mindspore/nn/layer/embedding.py +4 -169
- mindspore/nn/layer/normalization.py +2 -1
- mindspore/nn/layer/thor_layer.py +4 -85
- mindspore/nn/optim/ada_grad.py +0 -1
- mindspore/nn/optim/adafactor.py +0 -1
- mindspore/nn/optim/adam.py +31 -124
- mindspore/nn/optim/adamax.py +0 -1
- mindspore/nn/optim/asgd.py +0 -1
- mindspore/nn/optim/ftrl.py +8 -102
- mindspore/nn/optim/lamb.py +0 -1
- mindspore/nn/optim/lars.py +0 -3
- mindspore/nn/optim/lazyadam.py +25 -218
- mindspore/nn/optim/momentum.py +5 -43
- mindspore/nn/optim/optimizer.py +6 -55
- mindspore/nn/optim/proximal_ada_grad.py +0 -1
- mindspore/nn/optim/rmsprop.py +0 -1
- mindspore/nn/optim/rprop.py +0 -1
- mindspore/nn/optim/sgd.py +0 -1
- mindspore/nn/optim/tft_wrapper.py +0 -1
- mindspore/nn/optim/thor.py +0 -2
- mindspore/nn/probability/bijector/bijector.py +7 -8
- mindspore/nn/probability/bijector/gumbel_cdf.py +2 -2
- mindspore/nn/probability/bijector/power_transform.py +20 -21
- mindspore/nn/probability/bijector/scalar_affine.py +5 -5
- mindspore/nn/probability/bijector/softplus.py +13 -14
- mindspore/nn/wrap/grad_reducer.py +4 -74
- mindspore/numpy/array_creations.py +2 -2
- mindspore/numpy/fft.py +9 -9
- mindspore/{nn/reinforcement → onnx}/__init__.py +5 -8
- mindspore/onnx/onnx_export.py +137 -0
- mindspore/opencv_core4110.dll +0 -0
- mindspore/opencv_imgcodecs4110.dll +0 -0
- mindspore/{opencv_imgproc452.dll → opencv_imgproc4110.dll} +0 -0
- mindspore/ops/__init__.py +2 -0
- mindspore/ops/_grad_experimental/grad_comm_ops.py +38 -2
- mindspore/ops/_op_impl/aicpu/__init__.py +0 -10
- mindspore/ops/_op_impl/cpu/__init__.py +0 -5
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +16 -22
- mindspore/ops/auto_generate/gen_extend_func.py +2 -7
- mindspore/ops/auto_generate/gen_ops_def.py +98 -141
- mindspore/ops/auto_generate/gen_ops_prim.py +12708 -12686
- mindspore/ops/communication.py +97 -0
- mindspore/ops/composite/__init__.py +5 -2
- mindspore/ops/composite/base.py +15 -1
- mindspore/ops/composite/multitype_ops/__init__.py +3 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +150 -8
- mindspore/ops/composite/multitype_ops/add_impl.py +7 -0
- mindspore/ops/composite/multitype_ops/mod_impl.py +27 -0
- mindspore/ops/function/__init__.py +1 -0
- mindspore/ops/function/array_func.py +14 -12
- mindspore/ops/function/comm_func.py +3883 -0
- mindspore/ops/function/debug_func.py +3 -4
- mindspore/ops/function/math_func.py +45 -54
- mindspore/ops/function/nn_func.py +75 -294
- mindspore/ops/function/random_func.py +9 -18
- mindspore/ops/functional.py +2 -0
- mindspore/ops/functional_overload.py +354 -18
- mindspore/ops/operations/__init__.py +2 -5
- mindspore/ops/operations/_custom_ops_utils.py +7 -9
- mindspore/ops/operations/_inner_ops.py +1 -38
- mindspore/ops/operations/_rl_inner_ops.py +0 -933
- mindspore/ops/operations/array_ops.py +1 -0
- mindspore/ops/operations/comm_ops.py +94 -2
- mindspore/ops/operations/custom_ops.py +228 -19
- mindspore/ops/operations/debug_ops.py +27 -29
- mindspore/ops/operations/manually_defined/ops_def.py +27 -306
- mindspore/ops/operations/nn_ops.py +2 -2
- mindspore/ops/operations/sparse_ops.py +0 -83
- mindspore/ops/primitive.py +1 -17
- mindspore/ops/tensor_method.py +72 -3
- mindspore/ops_generate/aclnn/aclnn_kernel_register_auto_cc_generator.py +5 -5
- mindspore/ops_generate/aclnn/gen_aclnn_implement.py +8 -8
- mindspore/ops_generate/api/functions_cc_generator.py +53 -4
- mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +25 -11
- mindspore/ops_generate/common/gen_constants.py +11 -10
- mindspore/ops_generate/common/op_proto.py +18 -1
- mindspore/ops_generate/common/template.py +102 -245
- mindspore/ops_generate/common/template_utils.py +212 -0
- mindspore/ops_generate/gen_custom_ops.py +69 -0
- mindspore/ops_generate/op_def/ops_def_cc_generator.py +78 -7
- mindspore/ops_generate/op_def_py/base_op_prim_py_generator.py +360 -0
- mindspore/ops_generate/op_def_py/custom_op_prim_py_generator.py +140 -0
- mindspore/ops_generate/op_def_py/op_def_py_generator.py +54 -7
- mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -312
- mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +74 -17
- mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +22 -5
- mindspore/ops_generate/pyboost/op_template_parser.py +3 -2
- mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +21 -5
- mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +2 -2
- mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +30 -10
- mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +10 -3
- mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +19 -9
- mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +71 -28
- mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +10 -9
- mindspore/ops_generate/pyboost/pyboost_utils.py +27 -16
- mindspore/ops_generate/resources/yaml_loader.py +13 -0
- mindspore/ops_generate/tensor_py_cc_generator.py +2 -2
- mindspore/parallel/_cell_wrapper.py +1 -1
- mindspore/parallel/_parallel_serialization.py +1 -4
- mindspore/parallel/_utils.py +29 -6
- mindspore/parallel/checkpoint_transform.py +18 -2
- mindspore/parallel/cluster/process_entity/_api.py +24 -32
- mindspore/parallel/cluster/process_entity/_utils.py +9 -5
- mindspore/{experimental/llm_boost/atb → parallel/distributed}/__init__.py +21 -23
- mindspore/parallel/distributed/distributed_data_parallel.py +393 -0
- mindspore/parallel/distributed/flatten_grad_buffer.py +295 -0
- mindspore/parallel/strategy.py +336 -0
- mindspore/parallel/transform_safetensors.py +117 -16
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +3 -0
- mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +1 -1
- mindspore/profiler/common/constant.py +5 -0
- mindspore/profiler/common/file_manager.py +9 -0
- mindspore/profiler/common/msprof_cmd_tool.py +38 -2
- mindspore/profiler/common/path_manager.py +56 -24
- mindspore/profiler/common/profiler_context.py +2 -12
- mindspore/profiler/common/profiler_info.py +3 -3
- mindspore/profiler/common/profiler_path_manager.py +13 -0
- mindspore/profiler/common/util.py +30 -3
- mindspore/profiler/experimental_config.py +2 -1
- mindspore/profiler/platform/npu_profiler.py +33 -6
- mindspore/run_check/_check_version.py +108 -24
- mindspore/runtime/__init__.py +3 -2
- mindspore/runtime/executor.py +11 -3
- mindspore/runtime/memory.py +112 -0
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/{experimental/llm_boost → tools}/__init__.py +5 -5
- mindspore/tools/data_dump.py +130 -0
- mindspore/tools/sdc_detect.py +91 -0
- mindspore/tools/stress_detect.py +63 -0
- mindspore/train/__init__.py +6 -6
- mindspore/train/_utils.py +5 -18
- mindspore/train/amp.py +6 -4
- mindspore/train/callback/_checkpoint.py +0 -9
- mindspore/train/callback/_train_fault_tolerance.py +69 -18
- mindspore/train/data_sink.py +1 -5
- mindspore/train/model.py +38 -211
- mindspore/train/serialization.py +126 -387
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +6 -3
- mindspore/utils/dlpack.py +92 -0
- mindspore/utils/dryrun.py +1 -1
- mindspore/utils/runtime_execution_order_check.py +10 -0
- mindspore/utils/sdc_detect.py +14 -12
- mindspore/utils/stress_detect.py +43 -0
- mindspore/utils/utils.py +144 -8
- mindspore/version.py +1 -1
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/METADATA +3 -2
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/RECORD +254 -267
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +0 -210
- mindspore/experimental/llm_boost/ascend_native/llm_boost.py +0 -52
- mindspore/experimental/llm_boost/atb/boost_base.py +0 -385
- mindspore/experimental/llm_boost/atb/llama_boost.py +0 -137
- mindspore/experimental/llm_boost/atb/qwen_boost.py +0 -124
- mindspore/experimental/llm_boost/register.py +0 -130
- mindspore/experimental/llm_boost/utils.py +0 -31
- mindspore/include/OWNERS +0 -7
- mindspore/mindspore_cpu_res_manager.dll +0 -0
- mindspore/mindspore_ops_kernel_common.dll +0 -0
- mindspore/mindspore_res_manager.dll +0 -0
- mindspore/nn/optim/_dist_optimizer_registry.py +0 -111
- mindspore/nn/reinforcement/_batch_read_write.py +0 -142
- mindspore/nn/reinforcement/_tensors_queue.py +0 -152
- mindspore/nn/reinforcement/tensor_array.py +0 -145
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/ops/_op_impl/aicpu/priority_replay_buffer.py +0 -113
- mindspore/ops/_op_impl/aicpu/reservoir_replay_buffer.py +0 -96
- mindspore/ops/_op_impl/aicpu/sparse_cross.py +0 -42
- mindspore/ops/_op_impl/cpu/buffer_append.py +0 -28
- mindspore/ops/_op_impl/cpu/buffer_get.py +0 -28
- mindspore/ops/_op_impl/cpu/buffer_sample.py +0 -28
- mindspore/ops/_op_impl/cpu/priority_replay_buffer.py +0 -42
- mindspore/ops/operations/_tensor_array.py +0 -359
- mindspore/ops/operations/rl_ops.py +0 -288
- mindspore/parallel/_offload_context.py +0 -275
- mindspore/parallel/_recovery_context.py +0 -115
- mindspore/parallel/_transformer/__init__.py +0 -35
- mindspore/parallel/_transformer/layers.py +0 -765
- mindspore/parallel/_transformer/loss.py +0 -251
- mindspore/parallel/_transformer/moe.py +0 -693
- mindspore/parallel/_transformer/op_parallel_config.py +0 -222
- mindspore/parallel/_transformer/transformer.py +0 -3124
- mindspore/parallel/mpi/_mpi_config.py +0 -116
- mindspore/train/memory_profiling_pb2.py +0 -298
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/WHEEL +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.1.dist-info}/top_level.txt +0 -0
|
@@ -13,94 +13,27 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
# ============================================================================
|
|
15
15
|
"""Templates for code auto generation."""
|
|
16
|
-
|
|
16
|
+
__all__ = [
|
|
17
|
+
"Template",
|
|
18
|
+
"NEW_LINE",
|
|
19
|
+
"PYTHON_PRIM_TEMPLATE",
|
|
20
|
+
"IMPORT_PYBOOST_PRIM_HEADER",
|
|
21
|
+
"IMPORT_PYBOOST_FUNC_HEADER",
|
|
22
|
+
"PY_LICENSE_STR",
|
|
23
|
+
"OPS_PY_PRIM_HEADER",
|
|
24
|
+
"OPS_PY_DEF_HEADER",
|
|
25
|
+
"CUSTOM_OPS_PY_DEF_HEADER",
|
|
26
|
+
"PRIMITIVE_CLASS_DESC",
|
|
27
|
+
"CC_LICENSE_STR",
|
|
28
|
+
"OP_PROTO_TEMPLATE",
|
|
29
|
+
"OP_PRIM_CLASS_DEFINE_TEMPLATE",
|
|
30
|
+
]
|
|
31
|
+
|
|
17
32
|
import os
|
|
18
33
|
import common.gen_constants as K
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"""
|
|
23
|
-
template for generate c++/python code
|
|
24
|
-
"""
|
|
25
|
-
regular_str = r"(^[^\n\S]*)?\$([^\d\W]\w*|\{,?[^\d\W]\w*\,?})"
|
|
26
|
-
regular_match = re.compile(regular_str, re.MULTILINE)
|
|
27
|
-
|
|
28
|
-
def __init__(self, code_pattern):
|
|
29
|
-
self.code_pattern = code_pattern
|
|
30
|
-
|
|
31
|
-
@staticmethod
|
|
32
|
-
def load_from_file(file_path):
|
|
33
|
-
with open(file_path, "r") as f:
|
|
34
|
-
return Template(f.read())
|
|
35
|
-
|
|
36
|
-
def replace(self, **kwargs):
|
|
37
|
-
"""
|
|
38
|
-
replace param.
|
|
39
|
-
:param kwargs:
|
|
40
|
-
:return:
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
def find(key: str):
|
|
44
|
-
if key in kwargs:
|
|
45
|
-
return kwargs[key]
|
|
46
|
-
raise TypeError(f"{key} should be in kwargs!")
|
|
47
|
-
|
|
48
|
-
def add_indent(indent, var):
|
|
49
|
-
return "".join([indent + line + "\n" for data in var for line in str(data).splitlines()]).rstrip()
|
|
50
|
-
|
|
51
|
-
def extract_variable(key):
|
|
52
|
-
start = ""
|
|
53
|
-
end = ""
|
|
54
|
-
if key[0] == "{":
|
|
55
|
-
key = key[1:-1]
|
|
56
|
-
if key[0] == ",":
|
|
57
|
-
start = ","
|
|
58
|
-
key = key[1:]
|
|
59
|
-
if key[-1] == ",":
|
|
60
|
-
end = ", "
|
|
61
|
-
key = key[:-1]
|
|
62
|
-
return find(key), start, end
|
|
63
|
-
|
|
64
|
-
def match_rule(match):
|
|
65
|
-
indent = match.group(1)
|
|
66
|
-
key = match.group(2)
|
|
67
|
-
var, start, end = extract_variable(key)
|
|
68
|
-
if indent is not None:
|
|
69
|
-
if not isinstance(var, list):
|
|
70
|
-
return add_indent(indent, [var])
|
|
71
|
-
return add_indent(indent, var)
|
|
72
|
-
if isinstance(var, list):
|
|
73
|
-
code = ", ".join(str(x) for x in var)
|
|
74
|
-
if not var:
|
|
75
|
-
return code
|
|
76
|
-
return start + code + end
|
|
77
|
-
return str(var)
|
|
78
|
-
|
|
79
|
-
return self.regular_match.sub(match_rule, self.code_pattern)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
NEW_LINE = "\n"
|
|
83
|
-
|
|
84
|
-
PYTHON_PRIM_TEMPLATE = Template("""
|
|
85
|
-
|
|
86
|
-
class _Pyboost${class_name}Prim(${class_name}Prim_):
|
|
87
|
-
def __call__(self, ${input_args}):
|
|
88
|
-
${process_func}
|
|
89
|
-
return super().__call__([${processed_args}])
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
${func_impl_name}_impl = _Pyboost${class_name}Prim()
|
|
93
|
-
""")
|
|
94
|
-
|
|
95
|
-
IMPORT_PYBOOST_PRIM_HEADER = f"""
|
|
96
|
-
from mindspore.ops._utils.arg_handler import *
|
|
97
|
-
"""
|
|
98
|
-
|
|
99
|
-
IMPORT_PYBOOST_FUNC_HEADER = f"""
|
|
100
|
-
from mindspore.common import dtype as mstype
|
|
101
|
-
from mindspore.ops.auto_generate.pyboost_inner_prim import *
|
|
102
|
-
|
|
103
|
-
"""
|
|
34
|
+
from common.template_utils import Template, NEW_LINE, PYTHON_PRIM_TEMPLATE, IMPORT_PYBOOST_PRIM_HEADER, \
|
|
35
|
+
IMPORT_PYBOOST_FUNC_HEADER, PY_LICENSE_STR, OPS_PY_PRIM_HEADER, OPS_PY_DEF_HEADER, CUSTOM_OPS_PY_DEF_HEADER, \
|
|
36
|
+
PRIMITIVE_CLASS_DESC, CC_LICENSE_STR, OP_PROTO_TEMPLATE, OP_PRIM_CLASS_DEFINE_TEMPLATE
|
|
104
37
|
|
|
105
38
|
REGISTER_DEFINE_TEMPLATE = Template(
|
|
106
39
|
"""
|
|
@@ -117,13 +50,13 @@ REGISTER_PYBOOST_GRAD_DEFINE_TEMPLATE = Template(
|
|
|
117
50
|
REGISTER_PYBOOST_GRAD_TEMPLATE = Template("${register_func}")
|
|
118
51
|
|
|
119
52
|
PYBOOST_FUNCTION_HEADER_TEMPLATE = Template.load_from_file(
|
|
120
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
53
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_api_h.tpl'))
|
|
121
54
|
|
|
122
55
|
PYBOOST_CORE_HEADER_TEMPLATE = Template.load_from_file(
|
|
123
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
56
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_core_header.tpl'))
|
|
124
57
|
PYBOOST_INTERNAL_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
125
|
-
os.path.join(K.WORK_DIR,
|
|
126
|
-
f'
|
|
58
|
+
os.path.join(K.WORK_DIR, K.MS_OPS_KERNEL_PATH,
|
|
59
|
+
f'ascend/aclnn/pyboost_impl/internal/template/pyboost_internal_header_template.tpl'))
|
|
127
60
|
|
|
128
61
|
PYBOOST_INTERNAL_SINGLE_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
129
62
|
os.path.join(K.WORK_DIR,
|
|
@@ -178,96 +111,112 @@ PYBOOST_INTERNAL_KERNEL_INFO_ADAPTER_SINGLE_CPP_TEMPLATE = Template.load_from_fi
|
|
|
178
111
|
f'{K.MS_PLUGIN_INTERNAL_PATH}/pyboost/template/internal_kernel_info_adapter_single_cpp.tpl'))
|
|
179
112
|
|
|
180
113
|
PYBOOST_REGISTRY_BODY_CC_TEMPLATE = Template.load_from_file(
|
|
181
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
114
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_registry_body_cc.tpl'))
|
|
182
115
|
|
|
183
116
|
PYBOOST_CORE_BODY_TEMPLATE = Template.load_from_file(
|
|
184
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
117
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_core_body.tpl'))
|
|
118
|
+
|
|
119
|
+
PYBOOST_CORE_BODY_VIEW_TEMPLATE = Template.load_from_file(
|
|
120
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_core_body_view.tpl'))
|
|
185
121
|
|
|
186
122
|
PYBOOST_CORE_BODY_COMM_TEMPLATE = Template.load_from_file(
|
|
187
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
123
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_core_body_comm.tpl'))
|
|
188
124
|
|
|
189
125
|
PYBOOST_CORE_BODY_SYNC_TEMPLATE = Template.load_from_file(
|
|
190
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
126
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_core_body_sync.tpl'))
|
|
127
|
+
|
|
128
|
+
PYBOOST_CORE_BODY_VIEW_SYNC_TEMPLATE = Template.load_from_file(
|
|
129
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_core_body_view_sync.tpl'))
|
|
191
130
|
|
|
192
131
|
PYBOOST_REGISTRY_CC_TEMPLATE = Template.load_from_file(
|
|
193
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
132
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_registry_cc.tpl'))
|
|
194
133
|
|
|
195
134
|
PYBOOST_API_CC_TEMPLATE = Template.load_from_file(
|
|
196
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
135
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_api_cc.tpl'))
|
|
197
136
|
|
|
198
137
|
PYBOOST_API_BODY_CC_TEMPLATE = Template.load_from_file(
|
|
199
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
138
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_api_body_cc.tpl'))
|
|
200
139
|
|
|
201
140
|
PYBOOST_CORE_CC_TEMPLATE = Template.load_from_file(
|
|
202
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
141
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_core_cc.tpl'))
|
|
203
142
|
|
|
204
143
|
PYBOOST_OVERLOAD_FUNCTIONS_CC_TEMPLATE = Template.load_from_file(
|
|
205
144
|
os.path.join(
|
|
206
|
-
K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
145
|
+
K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_overload_functions_cc.tpl'))
|
|
207
146
|
|
|
208
147
|
PYBOOST_MINT_CLASS_DEF = Template.load_from_file(
|
|
209
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
148
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_mint_class_def.tpl'))
|
|
210
149
|
|
|
211
150
|
PYBOOST_OVERLOAD_MINT_CLASS_DEF = Template.load_from_file(
|
|
212
151
|
os.path.join(
|
|
213
|
-
K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
152
|
+
K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_overload_mint_class_def.tpl'))
|
|
214
153
|
|
|
215
154
|
# template path need to be moved
|
|
216
155
|
FUNCTIONAL_OVERLOAD_PY_TEMPLATE = Template.load_from_file(
|
|
217
156
|
os.path.join(
|
|
218
|
-
K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
157
|
+
K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/functional_overload_py.tpl')
|
|
219
158
|
)
|
|
220
159
|
|
|
221
160
|
TENSOR_FUNC_CC_REG = Template.load_from_file(
|
|
222
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
161
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/tensor_func_cc_reg.tpl'))
|
|
223
162
|
|
|
224
163
|
TENSOR_API_HEADER = Template.load_from_file(
|
|
225
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
164
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/tensor_api_header.tpl'))
|
|
226
165
|
|
|
227
166
|
TENSOR_API_SOURCE = Template.load_from_file(
|
|
228
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
167
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/tensor_api_source.tpl'))
|
|
229
168
|
|
|
230
169
|
TENSOR_FUNC_UTILS = Template.load_from_file(
|
|
231
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
170
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/tensor_func_utils_header.tpl'))
|
|
232
171
|
|
|
233
172
|
TENSOR_FUNC_CALL_BODY = Template.load_from_file(
|
|
234
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
173
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/tensor_func_call_body.tpl'))
|
|
235
174
|
|
|
236
175
|
TENSOR_FUNC_OVERLOAD_CALL_BODY = Template.load_from_file(
|
|
237
176
|
os.path.join(K.WORK_DIR,
|
|
238
|
-
'./mindspore/ccsrc/pynative/
|
|
177
|
+
'./mindspore/ccsrc/pynative/forward/pyboost/template/tensor_func_overload_call_body.tpl'))
|
|
239
178
|
|
|
240
179
|
TENSOR_FUNC_UT_BODY = Template.load_from_file(
|
|
241
180
|
os.path.join(K.WORK_DIR,
|
|
242
|
-
'./mindspore/ccsrc/pynative/
|
|
181
|
+
'./mindspore/ccsrc/pynative/forward/pyboost/template/tensor_func_ut_body.tpl'))
|
|
243
182
|
|
|
244
183
|
TENSOR_FUNC_UT_OVERLOAD_BODY = Template.load_from_file(
|
|
245
184
|
os.path.join(K.WORK_DIR,
|
|
246
|
-
'./mindspore/ccsrc/pynative/
|
|
185
|
+
'./mindspore/ccsrc/pynative/forward/pyboost/template/tensor_func_ut_overload_body.tpl'))
|
|
186
|
+
|
|
187
|
+
PYBOOST_OVERLOAD_UT_BODY = Template.load_from_file(
|
|
188
|
+
os.path.join(K.WORK_DIR,
|
|
189
|
+
'./mindspore/ccsrc/pynative/forward/pyboost/template/pyboost_overload_ut_body.tpl'))
|
|
247
190
|
|
|
248
191
|
TENSOR_CPP_METHOD = Template.load_from_file(
|
|
249
192
|
os.path.join(K.WORK_DIR,
|
|
250
|
-
'./mindspore/ccsrc/pynative/
|
|
193
|
+
'./mindspore/ccsrc/pynative/forward/pyboost/template/tensor_cpp_method.tpl'))
|
|
251
194
|
|
|
252
195
|
TENSOR_FUNC_CLASS_REG = Template.load_from_file(
|
|
253
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
196
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/tensor_func_class_reg.tpl'))
|
|
254
197
|
|
|
255
198
|
PYBOOST_GRAD_FUNCTION_TEMPLATE = Template.load_from_file(
|
|
256
199
|
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pyboost/grad_functions/template/pyboost_grad_function.tpl'))
|
|
257
200
|
|
|
201
|
+
PYBOOST_VIEW_GRAD_FUNCTION_TEMPLATE = Template.load_from_file(
|
|
202
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pyboost/grad_functions/template/pyboost_view_grad_function.tpl'))
|
|
203
|
+
|
|
258
204
|
PYBOOST_GRAD_HEADER_TEMPLATE = Template.load_from_file(
|
|
259
205
|
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pyboost/grad_functions/template/pyboost_grad_function_header.tpl'))
|
|
260
206
|
|
|
261
207
|
PYBOOST_NATIVE_GRAD_FUNCTION_TEMPLATE = Template.load_from_file(
|
|
262
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
208
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/backward/op_grad/template/native_grad_function.tpl'))
|
|
209
|
+
|
|
210
|
+
PYBOOST_NATIVE_VIEW_GRAD_FUNCTION_TEMPLATE = Template.load_from_file(
|
|
211
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/backward/op_grad/template/native_view_grad_function.tpl'))
|
|
263
212
|
|
|
264
213
|
PYBOOST_NATIVE_GRAD_FUNCTIONS_TEMPLATE = Template.load_from_file(
|
|
265
214
|
os.path.join(K.WORK_DIR,
|
|
266
|
-
'./mindspore/ccsrc/pynative/
|
|
215
|
+
'./mindspore/ccsrc/pynative/backward/op_grad/template/pyboost_native_grad_functions.tpl'))
|
|
267
216
|
|
|
268
217
|
PYBOOST_NATIVE_GRAD_FUNCTIONS_HEADER_TEMPLATE = Template.load_from_file(
|
|
269
218
|
os.path.join(K.WORK_DIR,
|
|
270
|
-
'./mindspore/ccsrc/pynative/
|
|
219
|
+
'./mindspore/ccsrc/pynative/backward/op_grad/template/pyboost_native_grad_functions_header.tpl'))
|
|
271
220
|
|
|
272
221
|
GEN_OPS_DEF_HEADER_TEMPLATE = Template.load_from_file(
|
|
273
222
|
os.path.join(K.WORK_DIR, './mindspore/python/mindspore/ops_generate/op_def/gen_ops_def_header.tpl'))
|
|
@@ -281,33 +230,33 @@ PYBOOST_OP_REGISTER_TEMPLATE = Template.load_from_file(
|
|
|
281
230
|
# Ascend op generate
|
|
282
231
|
PYBOOST_ASCEND_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
283
232
|
os.path.join(K.WORK_DIR,
|
|
284
|
-
f'./{K.MS_OPS_KERNEL_PATH}/ascend/
|
|
233
|
+
f'./{K.MS_OPS_KERNEL_PATH}/ascend/aclnn/pyboost_impl/template/pyboost_aclnn_header_template.tpl'))
|
|
285
234
|
PYBOOST_ASCEND_INTERNAL_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
286
|
-
os.path.join(K.WORK_DIR,
|
|
287
|
-
f'
|
|
235
|
+
os.path.join(K.WORK_DIR, K.MS_OPS_KERNEL_PATH,
|
|
236
|
+
f'ascend/aclnn/pyboost_impl/internal/template/pyboost_internal_header_template.tpl')
|
|
288
237
|
)
|
|
289
238
|
|
|
290
239
|
PYBOOST_ASCEND_OP_SOURCE_TEMPLATE = Template.load_from_file(
|
|
291
240
|
os.path.join(K.WORK_DIR,
|
|
292
|
-
f'./{K.MS_OPS_KERNEL_PATH}/ascend/
|
|
241
|
+
f'./{K.MS_OPS_KERNEL_PATH}/ascend/aclnn/pyboost_impl/template/pyboost_aclnn_source_template.tpl'))
|
|
293
242
|
|
|
294
243
|
PYBOOST_ASCEND_SINGLE_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
295
|
-
os.path.join(K.WORK_DIR,
|
|
296
|
-
f'
|
|
244
|
+
os.path.join(K.WORK_DIR, K.MS_OPS_KERNEL_PATH,
|
|
245
|
+
f'ascend/aclnn/pyboost_impl/template/pyboost_aclnn_single_op_header_template.tpl'))
|
|
297
246
|
|
|
298
247
|
PYBOOST_ASCEND_SINGLE_HCLL_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
299
|
-
os.path.join(K.WORK_DIR,
|
|
300
|
-
f'
|
|
248
|
+
os.path.join(K.WORK_DIR, K.MS_OPS_KERNEL_PATH,
|
|
249
|
+
f'ascend/aclnn/pyboost_impl/template/pyboost_aclnn_single_hccl_op_header_template.tpl'))
|
|
301
250
|
|
|
302
251
|
PYBOOST_CALL_FUNC_TEMPLATE = Template('${return_type} Call(${call_args_with_type}) override;')
|
|
303
252
|
|
|
304
253
|
PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE = Template.load_from_file(
|
|
305
|
-
os.path.join(K.WORK_DIR,
|
|
306
|
-
f'
|
|
254
|
+
os.path.join(K.WORK_DIR, K.MS_OPS_KERNEL_PATH,
|
|
255
|
+
f'ascend/aclnn/pyboost_impl/template/pyboost_aclnn_single_op_source_template.tpl'))
|
|
307
256
|
|
|
308
257
|
PYBOOST_ASCEND_CALL_TEMPLATE = Template.load_from_file(
|
|
309
258
|
os.path.join(K.WORK_DIR,
|
|
310
|
-
f'./{K.MS_OPS_KERNEL_PATH}/ascend/
|
|
259
|
+
f'./{K.MS_OPS_KERNEL_PATH}/ascend/aclnn/pyboost_impl/template/pyboost_ascend_call_template.tpl'))
|
|
311
260
|
|
|
312
261
|
PYBOOST_ASCEND_VIEW_CALL_TEMPLATE = Template.load_from_file(
|
|
313
262
|
os.path.join(K.WORK_DIR,
|
|
@@ -316,7 +265,7 @@ PYBOOST_ASCEND_VIEW_CALL_TEMPLATE = Template.load_from_file(
|
|
|
316
265
|
|
|
317
266
|
PYBOOST_ASCEND_CUSTOMIZE_CALL_TEMPLATE = Template.load_from_file(
|
|
318
267
|
os.path.join(K.WORK_DIR,
|
|
319
|
-
f'./{K.MS_OPS_KERNEL_PATH}/ascend/
|
|
268
|
+
f'./{K.MS_OPS_KERNEL_PATH}/ascend/aclnn/pyboost_impl/template'
|
|
320
269
|
'/pyboost_ascend_customize_call_template.tpl'))
|
|
321
270
|
|
|
322
271
|
# GPU op generate
|
|
@@ -390,30 +339,6 @@ def ${func_name}(${func_args}):
|
|
|
390
339
|
\"\"\"
|
|
391
340
|
return ${func_impl_name}_impl(${input_args})\n\n""")
|
|
392
341
|
|
|
393
|
-
OP_PROTO_TEMPLATE = Template("""
|
|
394
|
-
${func_impl_declaration}
|
|
395
|
-
OpDef g${class_name} = {
|
|
396
|
-
/*.name_=*/"${class_name}",
|
|
397
|
-
/*.args_=*/ {
|
|
398
|
-
${input_args}
|
|
399
|
-
},
|
|
400
|
-
/* .returns_ = */ {
|
|
401
|
-
${return_args}
|
|
402
|
-
},
|
|
403
|
-
/*.signatures_ =*/ {
|
|
404
|
-
${signatures}
|
|
405
|
-
},
|
|
406
|
-
/*.indexes_ =*/ {
|
|
407
|
-
${indexes}
|
|
408
|
-
},
|
|
409
|
-
/*.func_impl_=*/${func_impl_define},
|
|
410
|
-
/*.enable_dispatch_ =*/${enable_dispatch},
|
|
411
|
-
/*.is_view_ =*/${is_view},
|
|
412
|
-
/*.is_graph_view_ =*/${is_graph_view},
|
|
413
|
-
};
|
|
414
|
-
REGISTER_PRIMITIVE_OP_DEF(${class_name}, &g${class_name});
|
|
415
|
-
""")
|
|
416
|
-
|
|
417
342
|
MULTI_OUTPUT_TEMPLATE = """
|
|
418
343
|
ValuePtrList values;
|
|
419
344
|
(void)std::transform(op->outputs().begin(), op->outputs().end(), std::back_inserter(values),
|
|
@@ -421,86 +346,6 @@ ValuePtrList values;
|
|
|
421
346
|
auto output_value = std::make_shared<ValueTuple>(values);
|
|
422
347
|
"""
|
|
423
348
|
|
|
424
|
-
PY_LICENSE_STR = f"""# Copyright 2023 Huawei Technologies Co., Ltd
|
|
425
|
-
#
|
|
426
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
427
|
-
# you may not use this file except in compliance with the License.
|
|
428
|
-
# You may obtain a copy of the License at
|
|
429
|
-
#
|
|
430
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
431
|
-
#
|
|
432
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
433
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
434
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
435
|
-
# See the License for the specific language governing permissions and
|
|
436
|
-
# limitations under the License.
|
|
437
|
-
# ============================================================================
|
|
438
|
-
"""
|
|
439
|
-
|
|
440
|
-
OPS_PY_PRIM_HEADER = f"""
|
|
441
|
-
\"\"\"Operators definition generated by gen_ops.py, includes primitive classes.\"\"\"
|
|
442
|
-
|
|
443
|
-
from mindspore.ops.primitive import Primitive, prim_arg_register
|
|
444
|
-
from mindspore.ops import signature as sig
|
|
445
|
-
from mindspore.common import dtype as mstype
|
|
446
|
-
from mindspore.common._decorator import deprecated
|
|
447
|
-
from mindspore.ops._primitive_cache import _get_cache_prim
|
|
448
|
-
from mindspore.ops._utils.arg_dtype_cast import type_it
|
|
449
|
-
from mindspore.ops._utils.arg_handler import *
|
|
450
|
-
from mindspore._c_expression import OpDtype
|
|
451
|
-
from mindspore.common.jit_context import jit_context
|
|
452
|
-
from mindspore._checkparam import is_stub_tensor
|
|
453
|
-
"""
|
|
454
|
-
|
|
455
|
-
OP_PRIM_CLASS_DEFINE_TEMPLATE = Template("""
|
|
456
|
-
|
|
457
|
-
class ${class_name}(Primitive):
|
|
458
|
-
${class_desc}${signature_code}${deprecated_code}
|
|
459
|
-
${init_method}
|
|
460
|
-
|
|
461
|
-
${call_method}""")
|
|
462
|
-
|
|
463
|
-
OPS_PY_DEF_HEADER = f"""
|
|
464
|
-
\"\"\"Operators definition generated by gen_ops.py, includes functions.\"\"\"
|
|
465
|
-
|
|
466
|
-
from .gen_ops_prim import *
|
|
467
|
-
from .pyboost_inner_prim import *
|
|
468
|
-
from mindspore.ops.operations.manually_defined.ops_def import *
|
|
469
|
-
from mindspore.ops._primitive_cache import _get_cache_prim
|
|
470
|
-
"""
|
|
471
|
-
|
|
472
|
-
PRIMITIVE_CLASS_DESC = """ r\"\"\"
|
|
473
|
-
.. code-block::
|
|
474
|
-
|
|
475
|
-
prim = ops.$class_name($init_args_str)
|
|
476
|
-
out = prim($input_args_str)
|
|
477
|
-
|
|
478
|
-
is equivalent to
|
|
479
|
-
|
|
480
|
-
.. code-block::
|
|
481
|
-
|
|
482
|
-
ops.$func_name($args_str)
|
|
483
|
-
|
|
484
|
-
Refer to :func:`mindspore.ops.$func_name` for more details.
|
|
485
|
-
\"\"\"
|
|
486
|
-
"""
|
|
487
|
-
|
|
488
|
-
CC_LICENSE_STR = f"""/**
|
|
489
|
-
* Copyright 2023-2025 Huawei Technologies Co., Ltd
|
|
490
|
-
*
|
|
491
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
492
|
-
* you may not use this file except in compliance with the License.
|
|
493
|
-
* You may obtain a copy of the License at
|
|
494
|
-
*
|
|
495
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
496
|
-
*
|
|
497
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
498
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
499
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
500
|
-
* See the License for the specific language governing permissions and
|
|
501
|
-
* limitations under the License.
|
|
502
|
-
*/"""
|
|
503
|
-
|
|
504
349
|
arg_default_value = Template("""
|
|
505
350
|
\"\"\"Operator labels and args default value.\"\"\"
|
|
506
351
|
from mindspore.common import dtype as mstype
|
|
@@ -539,10 +384,10 @@ op_template = Template("""void ${op_name}::set_${arg_name}(const ${dtype} &${arg
|
|
|
539
384
|
""" { return GetValue<${dtype}>(GetAttr("${arg_name}")); }\n\n""")
|
|
540
385
|
|
|
541
386
|
ACLNN_KERNEL_CC_TEMPLATE = Template.load_from_file(
|
|
542
|
-
os.path.join(K.WORK_DIR, f'./{K.MS_OPS_KERNEL_PATH}/ascend/
|
|
387
|
+
os.path.join(K.WORK_DIR, f'./{K.MS_OPS_KERNEL_PATH}/ascend/aclnn/kernel_mod_impl/template/aclnn_kernel_cc.tpl'))
|
|
543
388
|
|
|
544
389
|
ACLNN_KERNEL_H_TEMPLATE = Template.load_from_file(
|
|
545
|
-
os.path.join(K.WORK_DIR, f'./{K.MS_OPS_KERNEL_PATH}/ascend/
|
|
390
|
+
os.path.join(K.WORK_DIR, f'./{K.MS_OPS_KERNEL_PATH}/ascend/aclnn/kernel_mod_impl/template/aclnn_kernel_h.tpl'))
|
|
546
391
|
|
|
547
392
|
update_output_shape_and_size_template = Template("""
|
|
548
393
|
void ${kernelmod_name}::UpdateOutputShapeAndSize(const std::vector<KernelTensor *> &,
|
|
@@ -562,39 +407,51 @@ TUPLE_TENSOR_NOT_SUPPORTED = Template("""
|
|
|
562
407
|
|
|
563
408
|
FUNCTIONAL_MAP_CC_TEMPLATE = Template.load_from_file(
|
|
564
409
|
os.path.join(K.WORK_DIR,
|
|
565
|
-
f'./mindspore/ccsrc/pynative/
|
|
410
|
+
f'./mindspore/ccsrc/pynative/forward/pyboost/template/functional_map_cc.tpl'))
|
|
566
411
|
|
|
567
412
|
FUNCTIONAL_MAP_H_TEMPLATE = Template.load_from_file(
|
|
568
413
|
os.path.join(K.WORK_DIR,
|
|
569
|
-
f'./mindspore/ccsrc/pynative/
|
|
414
|
+
f'./mindspore/ccsrc/pynative/forward/pyboost/template/functional_map_h.tpl'))
|
|
570
415
|
|
|
571
416
|
ADD_TENSOR_DOCS_TEMPLATE = Template.load_from_file(
|
|
572
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
417
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/tensor_docs_py.tpl'))
|
|
573
418
|
|
|
574
419
|
AUTO_GRAD_IMPL_CC_TEMPLATE = Template.load_from_file(
|
|
575
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
420
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/auto_grad_impl_cc.tpl'))
|
|
576
421
|
|
|
577
422
|
AUTO_GRAD_REG_H_TEMPLATE = Template.load_from_file(
|
|
578
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
423
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/auto_grad_reg_h.tpl'))
|
|
579
424
|
|
|
580
425
|
FUNCTIONS_CC_TEMPLATE = Template.load_from_file(
|
|
581
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
426
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/functions_cc.tpl'))
|
|
582
427
|
|
|
583
428
|
FUNCTION_BODY_TEMPLATE = Template.load_from_file(
|
|
584
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
429
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/function_body.tpl'))
|
|
430
|
+
|
|
431
|
+
FUNCTION_VIEW_BODY_TEMPLATE = Template.load_from_file(
|
|
432
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/function_view_body.tpl'))
|
|
433
|
+
|
|
434
|
+
FUNCTION_VIEW_CUSTOMIZE_BODY_TEMPLATE = Template.load_from_file(
|
|
435
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/function_view_customize_body.tpl'))
|
|
585
436
|
|
|
586
437
|
FUNCTION_COMM_BODY_TEMPLATE = Template.load_from_file(
|
|
587
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
438
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/comm_function_body.tpl'))
|
|
588
439
|
|
|
589
440
|
FUNCTIONS_H_TEMPLATE = Template.load_from_file(
|
|
590
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
441
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/functions_h.tpl'))
|
|
591
442
|
|
|
592
443
|
DO_GRAD_FUNCTION_BODY_TEMPLATE = Template.load_from_file(
|
|
593
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/
|
|
444
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/do_grad_function.tpl'))
|
|
445
|
+
|
|
446
|
+
DO_VIEW_GRAD_FUNCTION_BODY_TEMPLATE = Template.load_from_file(
|
|
447
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/do_view_grad_function.tpl'))
|
|
448
|
+
|
|
449
|
+
DO_VIEW_CUSTOMIZE_GRAD_FUNCTION_BODY_TEMPLATE = Template.load_from_file(
|
|
450
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/forward/pyboost/template/do_view_customize_grad_function.tpl'))
|
|
594
451
|
|
|
595
452
|
TENSOR_PY_CC_TEMPLATE = Template.load_from_file(
|
|
596
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pybind_api/ir/template/tensor_py_gen.tpl'))
|
|
453
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pybind_api/ir/tensor/template/tensor_py_gen.tpl'))
|
|
597
454
|
TENSOR_PY_H_TEMPLATE = Template.load_from_file(
|
|
598
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pybind_api/ir/template/tensor_py_genH.tpl'))
|
|
455
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pybind_api/ir/tensor/template/tensor_py_genH.tpl'))
|
|
599
456
|
OP_DEF_INC_HEAD_TEMPLATE = Template(
|
|
600
457
|
"#include \"mindspore/ops/op_def/auto_generate/gen_ops_primitive_${prefix_char}.h\"")
|