mindspore 2.2.10__cp37-cp37m-manylinux1_x86_64.whl → 2.2.14__cp37-cp37m-manylinux1_x86_64.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.

Files changed (162) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +2 -1
  3. mindspore/_akg/akg/composite/build_module.py +95 -5
  4. mindspore/_akg/akg/topi/cpp/impl.py +1 -1
  5. mindspore/_akg/akg/tvm/_ffi/base.py +1 -1
  6. mindspore/_akg/akg/utils/composite_op_helper.py +7 -2
  7. mindspore/_akg/akg/utils/dump_ascend_meta.py +22 -3
  8. mindspore/_akg/akg/utils/util.py +18 -1
  9. mindspore/_c_dataengine.cpython-37m-x86_64-linux-gnu.so +0 -0
  10. mindspore/_c_expression.cpython-37m-x86_64-linux-gnu.so +0 -0
  11. mindspore/_c_mindrecord.cpython-37m-x86_64-linux-gnu.so +0 -0
  12. mindspore/_extends/parse/__init__.py +3 -2
  13. mindspore/_extends/parse/parser.py +6 -1
  14. mindspore/_extends/parse/standard_method.py +12 -2
  15. mindspore/_mindspore_offline_debug.cpython-37m-x86_64-linux-gnu.so +0 -0
  16. mindspore/bin/cache_admin +0 -0
  17. mindspore/bin/cache_server +0 -0
  18. mindspore/common/_utils.py +16 -0
  19. mindspore/common/tensor.py +0 -2
  20. mindspore/communication/management.py +3 -0
  21. mindspore/context.py +34 -4
  22. mindspore/dataset/engine/cache_client.py +8 -5
  23. mindspore/dataset/engine/datasets.py +23 -0
  24. mindspore/dataset/engine/validators.py +1 -1
  25. mindspore/dataset/vision/py_transforms_util.py +2 -2
  26. mindspore/experimental/optim/lr_scheduler.py +5 -6
  27. mindspore/lib/libdnnl.so.2 +0 -0
  28. mindspore/lib/libmindspore_backend.so +0 -0
  29. mindspore/lib/libmindspore_common.so +0 -0
  30. mindspore/lib/libmindspore_core.so +0 -0
  31. mindspore/lib/libmindspore_glog.so.0 +0 -0
  32. mindspore/lib/libmindspore_gpr.so.15 +0 -0
  33. mindspore/lib/libmindspore_grpc++.so.1 +0 -0
  34. mindspore/lib/libmindspore_grpc.so.15 +0 -0
  35. mindspore/lib/libmindspore_shared_lib.so +0 -0
  36. mindspore/lib/libopencv_core.so.4.5 +0 -0
  37. mindspore/lib/libopencv_imgcodecs.so.4.5 +0 -0
  38. mindspore/lib/libopencv_imgproc.so.4.5 +0 -0
  39. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_aicpu_kernels.so +0 -0
  40. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_cpu_kernels.so +0 -0
  41. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/config/cust_aicpu_kernel.json +118 -0
  42. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_proto/libcust_op_proto.so +0 -0
  43. mindspore/lib/plugin/ascend/libakg.so +0 -0
  44. mindspore/lib/plugin/ascend/libascend_collective.so +0 -0
  45. mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
  46. mindspore/lib/plugin/ascend/libmindspore_aicpu_kernels.so +0 -0
  47. mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
  48. mindspore/lib/plugin/cpu/libakg.so +0 -0
  49. mindspore/lib/plugin/gpu/libcuda_ops.so.10 +0 -0
  50. mindspore/lib/plugin/gpu/libcuda_ops.so.11 +0 -0
  51. mindspore/lib/plugin/gpu10.1/libakg.so +0 -0
  52. mindspore/lib/plugin/gpu11.1/libakg.so +0 -0
  53. mindspore/lib/plugin/gpu11.1/libnccl.so.2 +0 -0
  54. mindspore/lib/plugin/gpu11.6/libakg.so +0 -0
  55. mindspore/lib/plugin/gpu11.6/libnccl.so.2 +0 -0
  56. mindspore/lib/plugin/libmindspore_ascend.so.1 +0 -0
  57. mindspore/lib/plugin/libmindspore_gpu.so.10.1 +0 -0
  58. mindspore/lib/plugin/libmindspore_gpu.so.11.1 +0 -0
  59. mindspore/lib/plugin/libmindspore_gpu.so.11.6 +0 -0
  60. mindspore/mindrecord/tools/cifar100_to_mr.py +49 -57
  61. mindspore/mindrecord/tools/cifar10_to_mr.py +46 -55
  62. mindspore/mindrecord/tools/csv_to_mr.py +3 -8
  63. mindspore/mindrecord/tools/mnist_to_mr.py +4 -9
  64. mindspore/mindrecord/tools/tfrecord_to_mr.py +1 -4
  65. mindspore/nn/layer/activation.py +1 -1
  66. mindspore/nn/layer/embedding.py +2 -2
  67. mindspore/nn/layer/flash_attention.py +48 -135
  68. mindspore/nn/loss/loss.py +1 -1
  69. mindspore/nn/optim/ada_grad.py +2 -2
  70. mindspore/nn/optim/sgd.py +3 -2
  71. mindspore/nn/wrap/__init__.py +4 -2
  72. mindspore/nn/wrap/cell_wrapper.py +6 -3
  73. mindspore/numpy/math_ops.py +1 -1
  74. mindspore/ops/__init__.py +3 -0
  75. mindspore/ops/_grad_experimental/grad_array_ops.py +0 -31
  76. mindspore/ops/_grad_experimental/grad_comm_ops.py +4 -2
  77. mindspore/ops/_grad_experimental/grad_inner_ops.py +8 -0
  78. mindspore/ops/_grad_experimental/grad_math_ops.py +37 -17
  79. mindspore/ops/_op_impl/aicpu/__init__.py +1 -0
  80. mindspore/ops/_op_impl/aicpu/generate_eod_mask.py +38 -0
  81. mindspore/ops/_op_impl/aicpu/linear_sum_assignment.py +21 -2
  82. mindspore/ops/function/array_func.py +6 -5
  83. mindspore/ops/function/debug_func.py +1 -1
  84. mindspore/ops/function/linalg_func.py +21 -11
  85. mindspore/ops/function/math_func.py +3 -0
  86. mindspore/ops/function/nn_func.py +13 -11
  87. mindspore/ops/function/parameter_func.py +2 -0
  88. mindspore/ops/function/sparse_unary_func.py +2 -2
  89. mindspore/ops/function/vmap_func.py +1 -0
  90. mindspore/ops/operations/__init__.py +5 -2
  91. mindspore/ops/operations/_embedding_cache_ops.py +1 -1
  92. mindspore/ops/operations/_grad_ops.py +3 -4
  93. mindspore/ops/operations/_inner_ops.py +56 -1
  94. mindspore/ops/operations/_quant_ops.py +4 -4
  95. mindspore/ops/operations/_rl_inner_ops.py +1 -1
  96. mindspore/ops/operations/array_ops.py +15 -4
  97. mindspore/ops/operations/custom_ops.py +1 -1
  98. mindspore/ops/operations/debug_ops.py +1 -1
  99. mindspore/ops/operations/image_ops.py +3 -3
  100. mindspore/ops/operations/inner_ops.py +49 -0
  101. mindspore/ops/operations/math_ops.py +65 -3
  102. mindspore/ops/operations/nn_ops.py +95 -28
  103. mindspore/ops/operations/random_ops.py +2 -0
  104. mindspore/ops/operations/sparse_ops.py +4 -4
  105. mindspore/ops/silent_check.py +162 -0
  106. mindspore/parallel/__init__.py +3 -2
  107. mindspore/parallel/_auto_parallel_context.py +82 -3
  108. mindspore/parallel/_parallel_serialization.py +34 -2
  109. mindspore/parallel/_tensor.py +3 -1
  110. mindspore/parallel/_transformer/transformer.py +8 -8
  111. mindspore/parallel/checkpoint_transform.py +191 -45
  112. mindspore/profiler/parser/ascend_cluster_generator.py +111 -0
  113. mindspore/profiler/parser/ascend_communicate_generator.py +315 -0
  114. mindspore/profiler/parser/ascend_flops_generator.py +8 -2
  115. mindspore/profiler/parser/ascend_fpbp_generator.py +8 -2
  116. mindspore/profiler/parser/ascend_hccl_generator.py +2 -2
  117. mindspore/profiler/parser/ascend_msprof_exporter.py +30 -6
  118. mindspore/profiler/parser/ascend_msprof_generator.py +16 -5
  119. mindspore/profiler/parser/ascend_op_generator.py +15 -7
  120. mindspore/profiler/parser/ascend_timeline_generator.py +5 -2
  121. mindspore/profiler/parser/base_timeline_generator.py +11 -3
  122. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +2 -1
  123. mindspore/profiler/parser/framework_parser.py +8 -2
  124. mindspore/profiler/parser/memory_usage_parser.py +8 -2
  125. mindspore/profiler/parser/minddata_analyzer.py +8 -2
  126. mindspore/profiler/parser/minddata_parser.py +1 -1
  127. mindspore/profiler/parser/msadvisor_analyzer.py +4 -2
  128. mindspore/profiler/parser/msadvisor_parser.py +9 -3
  129. mindspore/profiler/profiling.py +97 -25
  130. mindspore/rewrite/api/node.py +1 -1
  131. mindspore/rewrite/api/symbol_tree.py +2 -2
  132. mindspore/rewrite/parsers/for_parser.py +6 -6
  133. mindspore/rewrite/parsers/module_parser.py +4 -4
  134. mindspore/scipy/ops.py +55 -5
  135. mindspore/scipy/optimize/__init__.py +3 -2
  136. mindspore/scipy/optimize/linear_sum_assignment.py +38 -33
  137. mindspore/train/callback/_checkpoint.py +8 -8
  138. mindspore/train/callback/_landscape.py +2 -3
  139. mindspore/train/callback/_summary_collector.py +6 -7
  140. mindspore/train/dataset_helper.py +6 -0
  141. mindspore/train/model.py +17 -5
  142. mindspore/train/serialization.py +6 -1
  143. mindspore/train/summary/_writer_pool.py +1 -1
  144. mindspore/train/summary/summary_record.py +5 -6
  145. mindspore/version.py +1 -1
  146. {mindspore-2.2.10.dist-info → mindspore-2.2.14.dist-info}/METADATA +3 -2
  147. {mindspore-2.2.10.dist-info → mindspore-2.2.14.dist-info}/RECORD +150 -158
  148. mindspore/lib/plugin/libmindspore_ascend.so.2 +0 -0
  149. mindspore/ops/_op_impl/_custom_op/flash_attention/__init__.py +0 -0
  150. mindspore/ops/_op_impl/_custom_op/flash_attention/attention.py +0 -406
  151. mindspore/ops/_op_impl/_custom_op/flash_attention/constants.py +0 -41
  152. mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_bwd.py +0 -467
  153. mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_fwd.py +0 -563
  154. mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_impl.py +0 -193
  155. mindspore/ops/_op_impl/_custom_op/flash_attention/tik_ops_utils.py +0 -435
  156. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/__init__.py +0 -0
  157. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/sparse_tiling.py +0 -45
  158. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/strategy.py +0 -67
  159. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/wukong_tiling.py +0 -62
  160. {mindspore-2.2.10.dist-info → mindspore-2.2.14.dist-info}/WHEEL +0 -0
  161. {mindspore-2.2.10.dist-info → mindspore-2.2.14.dist-info}/entry_points.txt +0 -0
  162. {mindspore-2.2.10.dist-info → mindspore-2.2.14.dist-info}/top_level.txt +0 -0
mindspore/.commit_id CHANGED
@@ -1 +1 @@
1
- __commit_id__ = '[sha1]:93fa4635,[branch]:(HEAD,origin/r2.2.10-1,r2.2.10-1)'
1
+ __commit_id__ = '[sha1]:4f30cd5f,[branch]:(HEAD,origin/r2.2,r2.2)'
mindspore/__init__.py CHANGED
@@ -29,7 +29,8 @@ from mindspore.context import GRAPH_MODE, PYNATIVE_MODE, set_context, get_contex
29
29
  from mindspore.version import __version__
30
30
  from mindspore.profiler import Profiler, EnvProfiler
31
31
  from mindspore.parallel import set_algo_parameters, get_algo_parameters, reset_algo_parameters, \
32
- rank_list_for_transform, transform_checkpoint_by_rank, transform_checkpoints, merge_pipeline_strategys, shard
32
+ rank_list_for_transform, transform_checkpoint_by_rank, transform_checkpoints, merge_pipeline_strategys, shard, \
33
+ load_segmented_checkpoints
33
34
  from mindspore.rewrite import SymbolTree, ScopedValue, Node, NodeType, TreeNodeHelper
34
35
  from mindspore.safeguard import obfuscate_ckpt, load_obf_params_into_net
35
36
  from mindspore._check_jit_forbidden_api import get_obj_module_and_name_info, is_jit_forbidden_module, \
@@ -19,6 +19,7 @@ import os
19
19
  import json
20
20
  from collections.abc import Iterable
21
21
  import akg
22
+ import math
22
23
  from akg import tvm
23
24
  from tvm.autotvm.env import AutotvmGlobalScope
24
25
  from akg.utils.util import parse_workspace_map
@@ -314,12 +315,12 @@ def merge_attrs(attrs_a, attrs_b):
314
315
  return attrs
315
316
 
316
317
 
317
- def read_repo_file(repo_file):
318
+ def read_repo_file(repo_file, is_json_load=True):
318
319
  if not os.path.exists(repo_file):
319
320
  return {}
320
321
  with open(repo_file, 'r') as f:
321
- repo = json.loads(f.read())
322
- return repo
322
+ repo = f.read()
323
+ return json.loads(repo) if is_json_load else repo
323
324
 
324
325
 
325
326
  def _get_default_repository_file(process):
@@ -639,6 +640,7 @@ def _build_to_module_ascend(desc_s_in, desc_d_in, attr, use_repo=True):
639
640
  ConstructType.NORMAL: _normal_postprocess,
640
641
  }
641
642
  process = desc_d_in["process"]
643
+ kernel_name = desc_d_in['op']
642
644
  ascend_type = get_ascend_type(desc_d_in)
643
645
  ascend_type_to_section = {"Ascend910A": "1.6", "Ascend310P3": "1.7",
644
646
  "Ascend910B1": "2.1", "Ascend910B2": "2.2", "Ascend910B3": "2.3", "Ascend910B4": "2.4"}
@@ -650,10 +652,14 @@ def _build_to_module_ascend(desc_s_in, desc_d_in, attr, use_repo=True):
650
652
  attr["is_tbe_codegen"] = True
651
653
  attr["pragma_modshift"] = True
652
654
  segment_tree, segment_infos = get_construct_args(desc_s_in, attr, post_funcs)
655
+
656
+ if desc_d_in.get("enable_cce_lib"):
657
+ attr["enable_cce_lib"] = True
658
+ return _build_to_module_ascend_lib(desc_s_in, kernel_name)
659
+
653
660
  poly = True
654
661
  res = _cpp_build(attr, process, poly, segment_tree, segment_infos)
655
662
  if attr.get("is_tbe_codegen"):
656
- kernel_name = desc_d_in['op']
657
663
  stmt_json = akg.tvm.save_json(res[0], "0.8.0")
658
664
  args_json = []
659
665
  for buf in res[1]:
@@ -669,6 +675,90 @@ def _build_to_module_ascend(desc_s_in, desc_d_in, attr, use_repo=True):
669
675
  return kernel_name
670
676
  return res
671
677
 
678
+ def _build_to_module_ascend_lib(desc_s_in, kernel_name):
679
+ def _get_all_shape(shapes):
680
+ shape_split = shapes.split(".")
681
+ shape_list = []
682
+ for shape in shape_split:
683
+ if "-" in shape:
684
+ tmp_shape = shape.split("-")[0]
685
+ for _ in range(shape.count("-") + 1):
686
+ shape_list.append(tmp_shape)
687
+ else:
688
+ shape_list.append(shape)
689
+ return shape_list
690
+
691
+ def _get_tiling_info(desc_s):
692
+ compute, shape, dtype = generate_trait(desc_s)
693
+ tiling_info = {}
694
+ if "MatMul" in compute:
695
+ trans_a = compute.split("_")[1]
696
+ trans_b = compute.split("_")[-1].split(".")[0]
697
+
698
+ shape_list = _get_all_shape(shape)
699
+ bias_flag = int(len(shape_list) > 3)
700
+ tensor_A = shape_list[0]
701
+ tensor_B = shape_list[1]
702
+
703
+ tensor_A_split = tensor_A.split("_")
704
+ if len(tensor_A_split) > 2:
705
+ batch_size = int(tensor_A.split("_")[0])
706
+ else:
707
+ batch_size = 1
708
+ if trans_a == "1":
709
+ M = int(tensor_A_split[-1])
710
+ K = int(tensor_A_split[-2])
711
+ else:
712
+ M = int(tensor_A_split[-2])
713
+ K = int(tensor_A_split[-1])
714
+
715
+ if trans_b == "1":
716
+ N = int(tensor_B.split("_")[-2])
717
+ else:
718
+ N = int(tensor_B.split("_")[-1])
719
+ tensor_A_type = str(dtype.split("-")[0])
720
+ tiling_info = {"batch_size":batch_size, "M": M, "N": N, "K": K, "trans_a": int(trans_a), "trans_b": int(trans_b),
721
+ "tensor_A_type": tensor_A_type, "bias_flag": bias_flag, "op_type": "MatMul"}
722
+ elif "PagedAttention" in compute or "PagedAttentionMask" in compute:
723
+ shape_list = _get_all_shape(shape)
724
+ query = shape_list[0]
725
+ key_cache = shape_list[1]
726
+ table_shape = shape_list[3]
727
+
728
+ num_tokens = int(query.split("_")[0])
729
+ num_heads = int(query.split("_")[1])
730
+ embedding_size = int(query.split("_")[2])
731
+ num_blocks = int(key_cache.split("_")[0])
732
+ block_size = int(key_cache.split("_")[1])
733
+ kv_heads = int(key_cache.split("_")[2])
734
+
735
+ max_num_blocks_per_query = int(table_shape.split("_")[1])
736
+ tor = float(1.0 / math.sqrt(1.0 * embedding_size))
737
+
738
+ tiling_info = {"num_tokens": num_tokens, "num_heads": num_heads, "embedding_size": embedding_size,
739
+ "num_blocks": num_blocks, "block_size": block_size, "max_num_blocks_per_query": max_num_blocks_per_query,
740
+ "tor": tor, "kv_heads": kv_heads, "op_type": "PagedAttention"}
741
+ if "PagedAttentionMask" in compute:
742
+ mask_shape = shape_list[5]
743
+ tiling_info["mask"] = list(map(int, mask_shape.split("_")))
744
+ tiling_info["op_type"] = "PagedAttentionMask"
745
+ elif "ReshapeAndCache" in compute:
746
+ shape_list = _get_all_shape(shape)
747
+ kv = shape_list[0]
748
+
749
+ num_tokens = int(kv.split("_")[0])
750
+ num_heads = int(kv.split("_")[1])
751
+ head_size = int(kv.split("_")[2])
752
+
753
+ tiling_info = {"num_tokens": num_tokens, "num_heads": num_heads, "head_size": head_size,
754
+ "op_type": "ReshapeAndCache"}
755
+ return tiling_info
756
+
757
+ func = tvm.get_global_func("build_cce_lib")
758
+ tiling_info = _get_tiling_info(json.loads(desc_s_in))
759
+ func(kernel_name, tiling_info, None)
760
+ return kernel_name
761
+
672
762
  def _set_backend(desc_d):
673
763
  desc_d_process = desc_d
674
764
  for i, op in enumerate(desc_d.get("op_desc")):
@@ -766,4 +856,4 @@ def get_tiling_space(kernel_desc, level=1, attr=None):
766
856
  spaces['c0_mod'] = ret.c0_tile_mod_table.asnumpy().tolist()
767
857
  if level >= 2:
768
858
  spaces['tuning_space'] = ret.tiling_candidate.asnumpy().tolist()
769
- return spaces
859
+ return spaces
@@ -39,7 +39,7 @@ def _load_lib():
39
39
  lib_path = []
40
40
 
41
41
  pwd = os.path.dirname(os.path.realpath(__file__))
42
- paths = [os.path.realpath(pwd + "/../../lib"), os.path.realpath(pwd + "/../../../../../mindspore/lib")]
42
+ paths = [os.path.realpath(pwd + "/../../lib"), os.path.realpath(pwd + "/../../../../mindspore_lite/lib"), os.path.realpath(pwd + "/../../../../../mindspore/lib")]
43
43
  tar_so = "libakg.so"
44
44
  for path in paths:
45
45
  found_lib = False
@@ -56,7 +56,7 @@ def _load_lib():
56
56
  lib_path = []
57
57
 
58
58
  pwd = os.path.dirname(os.path.realpath(__file__))
59
- paths = [os.path.realpath(pwd + "/../../lib"), os.path.realpath(pwd + "/../../../../../mindspore/lib")]
59
+ paths = [os.path.realpath(pwd + "/../../lib"), os.path.realpath(pwd + "/../../../../mindspore_lite/lib"), os.path.realpath(pwd + "/../../../../../mindspore/lib")]
60
60
  tar_so = "libakg.so"
61
61
  for path in paths:
62
62
  found_lib = False
@@ -519,8 +519,13 @@ def _update_workspace_data(kernel_name, input_for_mod, output_indexes):
519
519
  kernel_desc = json.loads(kernel_json)
520
520
  if "workspace" in kernel_desc:
521
521
  workspace_bytes = kernel_desc["workspace"]["size"]
522
- item = np.full(workspace_bytes, np.nan, np.int8)
523
- workspace_tensors.append(item)
522
+ workspace_num = kernel_desc["workspace"]["num"]
523
+ if len(workspace_bytes) != workspace_num:
524
+ raise ValueError("workspace num %s and size shape %s are not equal!"
525
+ % (len(workspace_bytes), workspace_num))
526
+ for i in range(kernel_desc["workspace"]["num"]):
527
+ item = np.full(workspace_bytes[i], np.nan, np.int8)
528
+ workspace_tensors.append(item)
524
529
  else:
525
530
  logging.warning("Kernel json file %s not found", json_file)
526
531
 
@@ -24,9 +24,23 @@ import akg.tvm
24
24
  from akg.global_configs import get_kernel_meta_path
25
25
  from akg.utils.util import parse_workspace, write_code
26
26
 
27
+ def set_ascend910b(code, core_type, title_dict):
28
+ if len(core_type) == 0:
29
+ return
30
+ if core_type == "MIX":
31
+ title_dict["magic"] = "RT_DEV_BINARY_MAGIC_ELF"
32
+ title_dict["coreType"] = "MIX"
33
+ title_dict["intercoreSync"] = 1
34
+ title_dict["taskRation"] = "1:2"
35
+ elif core_type == "AIC":
36
+ title_dict["coreType"] = "AiCore"
37
+ title_dict["magic"] = "RT_DEV_BINARY_MAGIC_ELF_AICUBE"
38
+ elif core_type == "AIV":
39
+ title_dict["coreType"] = "VectorCore"
40
+ title_dict["magic"] = "RT_DEV_BINARY_MAGIC_ELF_AIVEC"
27
41
 
28
42
  @akg.tvm.register_func
29
- def tvm_callback_cce_postproc(code, block_dim=1, workspace=None):
43
+ def tvm_callback_cce_postproc(code, block_dim=1, workspace=None, core_type=""):
30
44
  """Function for dumping ascend meta."""
31
45
  if "__aicore__" in code:
32
46
  title_dict = {"magic": "RT_DEV_BINARY_MAGIC_ELF"}
@@ -35,8 +49,13 @@ def tvm_callback_cce_postproc(code, block_dim=1, workspace=None):
35
49
  title_dict = dict()
36
50
 
37
51
  # kernel name
38
- kernel_name = code.split("_kernel")[0].split(" ")[-1]
39
- title_dict["kernelName"] = kernel_name + "_kernel0"
52
+ if "_kernel" in code:
53
+ kernel_name = code.split("_kernel")[0].split(" ")[-1]
54
+ title_dict["kernelName"] = kernel_name + "_kernel0"
55
+ elif "_mix_aic" in code:
56
+ kernel_name = code.split("_mix_aic")[0].split(" ")[-1]
57
+ title_dict["kernelName"] = kernel_name
58
+ set_ascend910b(code, core_type, title_dict)
40
59
 
41
60
  # thread info
42
61
  title_dict["blockDim"] = block_dim
@@ -29,6 +29,20 @@ def parse_int_const(value):
29
29
  return value.value
30
30
  return None
31
31
 
32
+ def parse_workspace_array(workspace):
33
+ total_bytes = []
34
+ workspace_list = get_shape(workspace)
35
+ for ws in workspace_list:
36
+ total_bytes.append(parse_int_const(ws))
37
+
38
+ if total_bytes is None:
39
+ return None
40
+
41
+ workspace_dict = {
42
+ "num": len(total_bytes),
43
+ "size": total_bytes
44
+ }
45
+ return workspace_dict
32
46
 
33
47
  def parse_workspace_map(attrs):
34
48
  if not isinstance(attrs, akg.tvm.container.Map):
@@ -65,7 +79,10 @@ def parse_workspace(workspace):
65
79
 
66
80
  total_bytes = 0
67
81
  if "total_bytes" in workspace:
68
- total_bytes = parse_int_const(workspace["total_bytes"])
82
+ ws = workspace["total_bytes"]
83
+ if isinstance(ws, akg.tvm.container.Array):
84
+ return parse_workspace_array(ws)
85
+ total_bytes = parse_int_const(ws)
69
86
 
70
87
  if total_bytes is None or total_bytes == 0:
71
88
  return None
@@ -28,7 +28,8 @@ from .parser import (Parser, create_instance, is_supported_create_instance_type,
28
28
  convert_class_to_function, convert_cell_list_to_sequence, is_cell_list, get_obj_from_sequence,
29
29
  get_type, is_class_member_recursive, get_global_params, get_adapter_tensor_attr,
30
30
  get_obj_defined_from_obj_type, is_from_third_party_library, get_const_abs, get_const_round,
31
- get_const_len, is_adapter_tensor_class, is_adapter_parameter_class, convert_to_namedtuple)
31
+ get_const_len, is_adapter_tensor_class, is_adapter_parameter_class, convert_to_namedtuple,
32
+ is_module_list)
32
33
 
33
34
  __all__ = ['Parser', 'create_instance', 'is_supported_create_instance_type', 'generate_scope', 'get_attr_from_object',
34
35
  'get_bprop_method_of_class', 'get_class_instance_type', 'get_class_member_namespace_symbol',
@@ -41,4 +42,4 @@ __all__ = ['Parser', 'create_instance', 'is_supported_create_instance_type', 'ge
41
42
  'convert_class_to_function', 'convert_cell_list_to_sequence', 'is_cell_list', 'get_obj_from_sequence',
42
43
  'get_type', 'is_class_member_recursive', 'get_adapter_tensor_attr', 'get_obj_defined_from_obj_type',
43
44
  'is_from_third_party_library', 'get_const_abs', 'get_const_round', 'get_const_len',
44
- 'is_adapter_tensor_class', 'is_adapter_parameter_class', 'convert_to_namedtuple',]
45
+ 'is_adapter_tensor_class', 'is_adapter_parameter_class', 'convert_to_namedtuple', 'is_module_list']
@@ -493,9 +493,14 @@ def is_cell_list(obj):
493
493
  return isinstance(obj, nn.CellList)
494
494
 
495
495
 
496
+ def is_module_list(obj):
497
+ """Check if obj is nn.ModuleList"""
498
+ return hasattr(obj, "__cell_as_list__") and not isinstance(obj, nn.CellList)
499
+
500
+
496
501
  def convert_cell_list_to_sequence(obj):
497
502
  """Convert nn.CellList to sequence."""
498
- if not isinstance(obj, nn.CellList):
503
+ if not hasattr(obj, "__cell_as_list__"):
499
504
  raise TypeError(f"Obj should be nn.CellList, but got {obj}")
500
505
  if not hasattr(obj, "_cells"):
501
506
  raise AttributeError(f"nn.CellList is missing _cells property.")
@@ -2349,12 +2349,22 @@ def ms_iter(xs):
2349
2349
 
2350
2350
  def ms_next(it):
2351
2351
  """Implementation of `next`."""
2352
- return it.__ms_next__()
2352
+ return it.__ms_next__
2353
2353
 
2354
2354
 
2355
2355
  def hasnext(it):
2356
2356
  """Implementation of `hasnext`."""
2357
- return it.__ms_hasnext__()
2357
+ return it.__ms_hasnext__
2358
+
2359
+
2360
+ def str_next(xs):
2361
+ """Next string."""
2362
+ return xs[0], xs[1:]
2363
+
2364
+
2365
+ def str_hasnext(xs):
2366
+ """Whether the string is empty or not."""
2367
+ return len(xs) > 0
2358
2368
 
2359
2369
 
2360
2370
  @constexpr
mindspore/bin/cache_admin CHANGED
Binary file
Binary file
@@ -116,3 +116,19 @@ def load_lib(lib_path):
116
116
  logger.warning(f'Loading {lib_path} lib error.')
117
117
  return False
118
118
  return True
119
+
120
+
121
+ def _jit_fallback_next_func(xs):
122
+ """Generate ms_next for xs"""
123
+ if hasattr(xs, "__next__"):
124
+ # Convert an iterator to tuple first.
125
+ xs = tuple(xs)
126
+ return xs[0], xs[1:]
127
+
128
+
129
+ def _jit_fallback_has_next_func(xs):
130
+ """Determine whether xs has next value"""
131
+ if hasattr(xs, "__next__"):
132
+ # Convert an iterator to tuple first.
133
+ xs = tuple(xs)
134
+ return len(xs) > 0
@@ -959,8 +959,6 @@ class Tensor(Tensor_, metaclass=_TensorMeta):
959
959
  [11. 2.]
960
960
  """
961
961
  self._init_check()
962
- if self.dtype == mstype.bfloat16:
963
- raise TypeError(f"For asnumpy, the type of tensor cannot be BFloat16, but got {self.dtype}.")
964
962
  return Tensor_.asnumpy(self)
965
963
 
966
964
  def numpy(self):
@@ -74,6 +74,9 @@ def _check_parallel_envs():
74
74
  """
75
75
  if not GlobalComm.CHECK_ENVS:
76
76
  return
77
+ compile_level = os.getenv("MS_SIMULATION_LEVEL")
78
+ if compile_level:
79
+ return
77
80
  rank_id_str = os.getenv("RANK_ID")
78
81
  if not rank_id_str:
79
82
  raise RuntimeError("Environment variables RANK_ID has not been exported, please export variables 'RANK_ID'.")
mindspore/context.py CHANGED
@@ -284,7 +284,8 @@ class _Context:
284
284
  'conv_allow_hf32': [True, False],
285
285
  'exception_dump': ["0", "1", "2"],
286
286
  'op_precision_mode': (str,),
287
- 'parallel_speed_up_json_path': (str, None)
287
+ 'parallel_speed_up_json_path': (str, None),
288
+ 'topo_order': (dict,)
288
289
  }
289
290
  ascend_cfg_setters = {
290
291
  'precision_mode': self._get_ascend_config_setter('precision_mode'),
@@ -294,7 +295,8 @@ class _Context:
294
295
  'conv_allow_hf32': self._get_ascend_config_setter('conv_allow_hf32', lambda v: "1" if v else "0"),
295
296
  'exception_dump': self._get_ascend_config_setter('exception_dump'),
296
297
  'op_precision_mode': self._set_op_precision_mode,
297
- 'parallel_speed_up_json_path': self._set_speedup_config_path
298
+ 'parallel_speed_up_json_path': self._set_speedup_config_path,
299
+ 'topo_order': self._set_topo_order
298
300
  }
299
301
  ascend_cfg_set = tuple(ascend_cfg_modes.keys())
300
302
  for ascend_key, ascend_value in ascend_config.items():
@@ -618,6 +620,28 @@ class _Context:
618
620
  f"got '{op_precision_path}'.")
619
621
  self.set_param(ms_ctx_param.op_precision_mode, ascend_value)
620
622
 
623
+ def _set_topo_order(self, topo_order):
624
+ """
625
+ Set topo order.
626
+
627
+ Args:
628
+ topo_order (dict):
629
+ key: str, the name of the graph.
630
+ value: str, the topo order of the graph, should be one of 'dfs', 'bfs', 'rdfs'.
631
+ """
632
+ valid_order = {'dfs', 'bfs', 'rdfs'}
633
+ if not isinstance(topo_order, dict):
634
+ raise TypeError(f"For 'ascend_config', the 'topo_order' should be a dict, "
635
+ f"got '{type(topo_order)}'.")
636
+ for k, v in topo_order.items():
637
+ if not isinstance(k, str):
638
+ raise TypeError("key {} is not a str".format(k))
639
+ if v not in valid_order:
640
+ raise ValueError("value {} should be one of {}.".format(v, valid_order))
641
+
642
+ options_str = json.dumps(topo_order)
643
+ self.set_param(ms_ctx_param.topo_order, options_str)
644
+
621
645
  def _set_speedup_config_path(self, speedup_config_path):
622
646
  """"Check and set speedup config for auto parallel."""
623
647
  if speedup_config_path is None or speedup_config_path == "":
@@ -681,7 +705,7 @@ def _context():
681
705
  auto_parallel_search_mode=str, search_mode=str, parameter_broadcast=bool, strategy_ckpt_load_file=str,
682
706
  strategy_ckpt_save_file=str, full_batch=bool, enable_parallel_optimizer=bool, enable_alltoall=bool,
683
707
  all_reduce_fusion_config=list, pipeline_stages=int, pipeline_segments=int,
684
- parallel_optimizer_config=dict,
708
+ pipeline_config=dict, parallel_optimizer_config=dict,
685
709
  comm_fusion=dict, strategy_ckpt_config=dict)
686
710
  def set_auto_parallel_context(**kwargs):
687
711
  r"""
@@ -708,7 +732,7 @@ def set_auto_parallel_context(**kwargs):
708
732
  enable_parallel_optimizer strategy_ckpt_save_file
709
733
  parallel_optimizer_config dataset_strategy
710
734
  enable_alltoall pipeline_stages
711
- \ auto_parallel_search_mode
735
+ pipeline_config auto_parallel_search_mode
712
736
  \ comm_fusion
713
737
  \ strategy_ckpt_config
714
738
  =========================== ===========================
@@ -777,6 +801,12 @@ def set_auto_parallel_context(**kwargs):
777
801
  distributed alone in the pipeline. The total devices will be divided into 'pipeline_stags'
778
802
  stages.
779
803
  Default: ``1`` .
804
+ pipeline_config (dict): A dict contains the keys and values for setting the pipeline parallelism configuration.
805
+ It supports the following keys:
806
+
807
+ - pipeline_interleave(bool): Indicates whether to enable the interleaved execution mode.
808
+ - pipeline_scheduler(str): Indicates the scheduling mode for pipeline parallelism. Only support
809
+ ``gpipe/1f1b``.
780
810
  parallel_optimizer_config (dict): A dict contains the keys and values for setting the parallel optimizer
781
811
  configure. The configure provides more detailed behavior control about parallel training
782
812
  when parallel optimizer is enabled. The configure will be effective when we use
@@ -23,7 +23,7 @@ from ..core.validator_helpers import type_check, check_pos_int32, check_pos_uint
23
23
 
24
24
 
25
25
  class DatasetCache:
26
- """
26
+ r"""
27
27
  A client to interface with tensor caching service.
28
28
 
29
29
  For details, please check `Tutorial <https://www.mindspore.cn/
@@ -46,7 +46,8 @@ class DatasetCache:
46
46
  >>>
47
47
  >>> # Create a cache instance with command line `cache_admin --start` and create a session with `cache_admin -g`
48
48
  >>> # After creating cache with a valid session, get session id with command `cache_admin --list_sessions`
49
- >>> session_id = subprocess.getoutput('cache_admin --list_sessions | tail -1 | awk -F " " \'{{print $1;}}\'')
49
+ >>> command = "cache_admin --list_sessions | tail -1 | awk -F ' ' '{{print $1;}}'"
50
+ >>> session_id = subprocess.getoutput(command).split('\n')[-1]
50
51
  >>> some_cache = ds.DatasetCache(session_id=int(session_id), size=0)
51
52
  >>>
52
53
  >>> dataset_dir = "/path/to/image_folder_dataset_directory"
@@ -81,18 +82,20 @@ class DatasetCache:
81
82
  self.cache_client = CacheClient(session_id, size, spilling, hostname, port, num_connections, prefetch_size)
82
83
 
83
84
  def get_stat(self):
84
- """
85
+ r"""
85
86
  Get the statistics from a cache. After data pipeline, three types of statistics can be obtained,
86
87
  including average number of cache hits (avg_cache_sz), number of caches in memory (num_mem_cached)
87
88
  and number of caches in disk (num_disk_cached).
88
89
 
89
90
  Examples:
90
91
  >>> import os
92
+ >>> import subprocess
91
93
  >>> import mindspore.dataset as ds
92
94
  >>>
93
95
  >>> # In example above, we created cache with a valid session id
94
- >>> id = int(os.popen('cache_admin --list_sessions | tail -1 | awk -F " " \'{{print $1;}}\'').read())
95
- >>> some_cache = ds.DatasetCache(session_id=id, size=0)
96
+ >>> command = "cache_admin --list_sessions | tail -1 | awk -F ' ' '{{print $1;}}'"
97
+ >>> id = subprocess.getoutput(command).split('\n')[-1]
98
+ >>> some_cache = ds.DatasetCache(session_id=int(id), size=0)
96
99
  >>>
97
100
  >>> # run the dataset pipeline to trigger cache
98
101
  >>> dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory", cache=some_cache)
@@ -4051,6 +4051,15 @@ class ConcatDataset(UnionBaseDataset):
4051
4051
 
4052
4052
  self._sampler = sampler
4053
4053
  self._children_sizes = [c.get_dataset_size() for c in self.children]
4054
+
4055
+ # Recursive access to other child concat nodes
4056
+ def set_child(node):
4057
+ for c in node.children:
4058
+ if isinstance(c, ConcatDataset):
4059
+ c.use_sampler(sampler)
4060
+ set_child(c)
4061
+ set_child(self)
4062
+
4054
4063
  return
4055
4064
 
4056
4065
  if sampler.is_shuffled():
@@ -4186,6 +4195,12 @@ class _ToDevice:
4186
4195
  """
4187
4196
  return self._to_device.GetDataInfo()
4188
4197
 
4198
+ def get_mbuf_queue_size(self):
4199
+ """
4200
+ Get element numbers inside mbuf.
4201
+ """
4202
+ return self._to_device.GetMbufQueueSize()
4203
+
4189
4204
  def get_send_info(self):
4190
4205
  """
4191
4206
  In sink mode, it returns the send information of dataset at this moment.
@@ -4300,6 +4315,14 @@ class TransferDataset(Dataset):
4300
4315
  return self._to_device.get_data_info()
4301
4316
  raise RuntimeError("Calling get_data_info with bad state.")
4302
4317
 
4318
+ def get_mbuf_queue_size(self):
4319
+ """
4320
+ Get element numbers inside mbuf.
4321
+ """
4322
+ if self._to_device is not None:
4323
+ return self._to_device.get_mbuf_queue_size()
4324
+ raise RuntimeError("Device queue is not init, call get_mbuf_queue_size failed.")
4325
+
4303
4326
  def get_send_info(self):
4304
4327
  """
4305
4328
  In sink mode, it returns the send information of dataset at this moment.
@@ -1021,7 +1021,7 @@ def check_minddataset(method):
1021
1021
  dataset_file = param_dict.get('dataset_files')
1022
1022
  if isinstance(dataset_file, list):
1023
1023
  if len(dataset_file) > 4096:
1024
- raise ValueError("length of dataset_file should be less than or equal to {}.".format(4096))
1024
+ log.warning("The number of MindRecord files greater than 4096 may cause slow dataset initialization.")
1025
1025
  for f in dataset_file:
1026
1026
  check_file(f)
1027
1027
  else:
@@ -1032,8 +1032,8 @@ def perspective(img, start_points, end_points, interpolation=Inter.BICUBIC):
1032
1032
  for pt1, pt2 in zip(transformed_points, original_points):
1033
1033
  matrix.append([pt1[0], pt1[1], 1, 0, 0, 0, -pt2[0] * pt1[0], -pt2[0] * pt1[1]])
1034
1034
  matrix.append([0, 0, 0, pt1[0], pt1[1], 1, -pt2[1] * pt1[0], -pt2[1] * pt1[1]])
1035
- matrix_a = np.array(matrix, dtype=np.float)
1036
- matrix_b = np.array(original_points, dtype=np.float).reshape(8)
1035
+ matrix_a = np.array(matrix, dtype=float)
1036
+ matrix_b = np.array(original_points, dtype=float).reshape(8)
1037
1037
  res = np.linalg.lstsq(matrix_a, matrix_b, rcond=None)[0]
1038
1038
  return res.tolist()
1039
1039
 
@@ -64,12 +64,11 @@ class LRScheduler:
64
64
  ... super(ConstantLR, self).__init__(optimizer, last_epoch)
65
65
  ...
66
66
  ... def get_lr(self):
67
- ... lrs = [lr.value() for lr in self._last_lr]
68
67
  ... if self.last_epoch == 0:
69
- ... return [lr * self.factor for lr in lrs]
68
+ ... return [lr * self.factor for lr in self._last_lr]
70
69
  ... if self.last_epoch != self.total_iters:
71
- ... return lrs
72
- ... return sreturn [lr / self.factor for lr in lrs]
70
+ ... return [lr * 1. for lr in self._last_lr]
71
+ ... return [lr / self.factor for lr in self._last_lr]
73
72
  >>>
74
73
  >>> net = nn.Dense(8, 2)
75
74
  >>> optimizer = optim.SGD(net.trainable_params(), 0.01)
@@ -913,7 +912,7 @@ class ReduceLROnPlateau:
913
912
  >>> metrics = [1, 1.5, 1.8, 0.4, 0.5]
914
913
  >>> for i in range(5):
915
914
  ... scheduler.step(metrics[i])
916
- ... current_lr = scheduler._last_lr
915
+ ... current_lr = scheduler.get_last_lr()
917
916
  ... print(current_lr)
918
917
  [Tensor(shape=[], dtype=Float32, value= 0.1)]
919
918
  [Tensor(shape=[], dtype=Float32, value= 0.01)]
@@ -1258,7 +1257,7 @@ class CosineAnnealingWarmRestarts(LRScheduler):
1258
1257
  >>> optimizer = optim.SGD(net.trainable_params(), lr=0.1, momentum=0.9)
1259
1258
  >>> scheduler = optim.lr_scheduler.CosineAnnealingWarmRestarts(optimizer, 2)
1260
1259
  >>> iters = 3
1261
- >>> for epoch in range(4):
1260
+ >>> for epoch in range(2):
1262
1261
  ... for i in range(iters):
1263
1262
  ... scheduler.step(epoch + i / iters)
1264
1263
  ... current_lr = scheduler.get_last_lr()
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file