mindspore 2.3.0rc1__cp39-cp39-manylinux1_x86_64.whl → 2.3.0rc2__cp39-cp39-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.
- mindspore/.commit_id +1 -1
- mindspore/__init__.py +1 -1
- mindspore/_akg/akg/utils/tbe_codegen_utils.py +13 -3
- mindspore/_c_dataengine.cpython-39-x86_64-linux-gnu.so +0 -0
- mindspore/_c_expression.cpython-39-x86_64-linux-gnu.so +0 -0
- mindspore/_checkparam.py +20 -0
- mindspore/_extends/parse/parser.py +1 -1
- mindspore/_extends/parse/standard_method.py +6 -5
- mindspore/_mindspore_offline_debug.cpython-39-x86_64-linux-gnu.so +0 -0
- mindspore/amp.py +5 -5
- mindspore/bin/cache_admin +0 -0
- mindspore/bin/cache_server +0 -0
- mindspore/boost/boost_cell_wrapper.py +1 -1
- mindspore/boost/group_loss_scale_manager.py +1 -1
- mindspore/common/__init__.py +4 -2
- mindspore/common/_register_for_recompute.py +48 -0
- mindspore/common/_stub_tensor.py +1 -0
- mindspore/common/api.py +56 -4
- mindspore/common/dtype.py +5 -3
- mindspore/common/dump.py +2 -2
- mindspore/common/hook_handle.py +51 -4
- mindspore/common/initializer.py +1 -1
- mindspore/common/jit_config.py +17 -6
- mindspore/common/parameter.py +7 -2
- mindspore/common/recompute.py +247 -0
- mindspore/common/sparse_tensor.py +2 -2
- mindspore/common/symbol.py +1 -1
- mindspore/common/tensor.py +74 -36
- mindspore/communication/__init__.py +3 -3
- mindspore/communication/management.py +30 -30
- mindspore/context.py +28 -15
- mindspore/dataset/__init__.py +5 -5
- mindspore/dataset/audio/__init__.py +2 -2
- mindspore/dataset/audio/transforms.py +51 -51
- mindspore/dataset/callback/ds_callback.py +2 -2
- mindspore/dataset/engine/cache_client.py +1 -1
- mindspore/dataset/engine/datasets.py +3 -3
- mindspore/dataset/engine/datasets_audio.py +14 -14
- mindspore/dataset/engine/datasets_standard_format.py +3 -3
- mindspore/dataset/engine/datasets_text.py +38 -38
- mindspore/dataset/engine/datasets_user_defined.py +3 -3
- mindspore/dataset/engine/datasets_vision.py +68 -68
- mindspore/dataset/text/__init__.py +3 -3
- mindspore/dataset/text/transforms.py +26 -26
- mindspore/dataset/transforms/__init__.py +1 -1
- mindspore/dataset/vision/__init__.py +3 -3
- mindspore/dataset/vision/transforms.py +92 -92
- mindspore/dataset/vision/utils.py +1 -1
- mindspore/experimental/optim/adadelta.py +2 -2
- mindspore/experimental/optim/adagrad.py +2 -2
- mindspore/experimental/optim/adam.py +2 -2
- mindspore/experimental/optim/adamax.py +2 -2
- mindspore/experimental/optim/adamw.py +2 -2
- mindspore/experimental/optim/asgd.py +2 -2
- mindspore/experimental/optim/lr_scheduler.py +24 -20
- mindspore/experimental/optim/nadam.py +2 -2
- mindspore/experimental/optim/optimizer.py +1 -1
- mindspore/experimental/optim/radam.py +2 -2
- mindspore/experimental/optim/rmsprop.py +2 -2
- mindspore/experimental/optim/rprop.py +2 -2
- mindspore/experimental/optim/sgd.py +2 -2
- mindspore/hal/stream.py +2 -0
- mindspore/include/mindapi/base/types.h +5 -0
- mindspore/lib/libdnnl.so.2 +0 -0
- mindspore/lib/libmindspore.so +0 -0
- mindspore/lib/libmindspore_backend.so +0 -0
- mindspore/lib/libmindspore_common.so +0 -0
- mindspore/lib/libmindspore_core.so +0 -0
- mindspore/lib/libmindspore_glog.so.0 +0 -0
- mindspore/lib/libmindspore_gpr.so.15 +0 -0
- mindspore/lib/libmindspore_grpc++.so.1 +0 -0
- mindspore/lib/libmindspore_grpc.so.15 +0 -0
- mindspore/lib/libmindspore_shared_lib.so +0 -0
- mindspore/lib/libopencv_core.so.4.5 +0 -0
- mindspore/lib/libopencv_imgcodecs.so.4.5 +0 -0
- mindspore/lib/libopencv_imgproc.so.4.5 +0 -0
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_cpu_kernels.so +0 -0
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/config/cust_aicpu_kernel.json +6 -6
- mindspore/lib/plugin/ascend/custom_aicpu_ops/op_proto/libcust_op_proto.so +0 -0
- mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
- mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
- mindspore/lib/plugin/gpu/libcuda_ops.so.10 +0 -0
- mindspore/lib/plugin/gpu/libcuda_ops.so.11 +0 -0
- mindspore/lib/plugin/gpu10.1/libnccl.so.2 +0 -0
- mindspore/lib/plugin/gpu11.1/libnccl.so.2 +0 -0
- mindspore/lib/plugin/gpu11.6/libnccl.so.2 +0 -0
- mindspore/lib/plugin/libmindspore_ascend.so.2 +0 -0
- mindspore/lib/plugin/libmindspore_gpu.so.10.1 +0 -0
- mindspore/lib/plugin/libmindspore_gpu.so.11.1 +0 -0
- mindspore/lib/plugin/libmindspore_gpu.so.11.6 +0 -0
- mindspore/log.py +2 -2
- mindspore/mint/__init__.py +457 -0
- mindspore/mint/nn/__init__.py +430 -0
- mindspore/mint/nn/functional.py +424 -0
- mindspore/mint/optim/__init__.py +24 -0
- mindspore/mint/optim/adamw.py +186 -0
- mindspore/multiprocessing/__init__.py +4 -0
- mindspore/nn/__init__.py +3 -0
- mindspore/nn/cell.py +51 -47
- mindspore/nn/extend/__init__.py +29 -0
- mindspore/nn/extend/basic.py +140 -0
- mindspore/nn/extend/embedding.py +143 -0
- mindspore/nn/extend/layer/__init__.py +27 -0
- mindspore/nn/extend/layer/normalization.py +107 -0
- mindspore/nn/extend/pooling.py +117 -0
- mindspore/nn/generator.py +297 -0
- mindspore/nn/layer/basic.py +109 -1
- mindspore/nn/layer/container.py +2 -2
- mindspore/nn/layer/conv.py +6 -6
- mindspore/nn/layer/embedding.py +1 -1
- mindspore/nn/layer/normalization.py +21 -43
- mindspore/nn/layer/padding.py +4 -0
- mindspore/nn/optim/ada_grad.py +2 -2
- mindspore/nn/optim/adadelta.py +1 -1
- mindspore/nn/optim/adafactor.py +1 -1
- mindspore/nn/optim/adam.py +7 -7
- mindspore/nn/optim/adamax.py +2 -2
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/asgd.py +2 -2
- mindspore/nn/optim/ftrl.py +1 -1
- mindspore/nn/optim/lamb.py +3 -3
- mindspore/nn/optim/lars.py +1 -1
- mindspore/nn/optim/lazyadam.py +2 -2
- mindspore/nn/optim/momentum.py +2 -2
- mindspore/nn/optim/optimizer.py +2 -2
- mindspore/nn/optim/proximal_ada_grad.py +2 -2
- mindspore/nn/optim/rmsprop.py +2 -2
- mindspore/nn/optim/rprop.py +2 -2
- mindspore/nn/optim/sgd.py +2 -2
- mindspore/nn/optim/thor.py +2 -2
- mindspore/nn/wrap/cell_wrapper.py +9 -9
- mindspore/nn/wrap/grad_reducer.py +5 -5
- mindspore/ops/_grad_experimental/grad_comm_ops.py +4 -2
- mindspore/ops/_vmap/vmap_grad_nn_ops.py +41 -2
- mindspore/ops/_vmap/vmap_math_ops.py +27 -8
- mindspore/ops/_vmap/vmap_nn_ops.py +66 -8
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +73 -1
- mindspore/ops/auto_generate/gen_arg_dtype_cast.py +12 -3
- mindspore/ops/auto_generate/gen_arg_handler.py +24 -0
- mindspore/ops/auto_generate/gen_extend_func.py +274 -0
- mindspore/ops/auto_generate/gen_ops_def.py +889 -22
- mindspore/ops/auto_generate/gen_ops_prim.py +3541 -253
- mindspore/ops/auto_generate/pyboost_inner_prim.py +282 -0
- mindspore/ops/composite/multitype_ops/_compile_utils.py +2 -1
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +9 -0
- mindspore/ops/extend/__init__.py +9 -1
- mindspore/ops/extend/array_func.py +134 -27
- mindspore/ops/extend/math_func.py +3 -3
- mindspore/ops/extend/nn_func.py +363 -2
- mindspore/ops/function/__init__.py +19 -2
- mindspore/ops/function/array_func.py +463 -439
- mindspore/ops/function/clip_func.py +7 -18
- mindspore/ops/function/grad/grad_func.py +5 -5
- mindspore/ops/function/linalg_func.py +4 -4
- mindspore/ops/function/math_func.py +260 -243
- mindspore/ops/function/nn_func.py +825 -62
- mindspore/ops/function/random_func.py +73 -4
- mindspore/ops/function/sparse_unary_func.py +1 -1
- mindspore/ops/function/vmap_func.py +1 -1
- mindspore/ops/functional.py +2 -2
- mindspore/ops/op_info_register.py +1 -31
- mindspore/ops/operations/__init__.py +2 -3
- mindspore/ops/operations/_grad_ops.py +2 -107
- mindspore/ops/operations/_inner_ops.py +5 -5
- mindspore/ops/operations/_sequence_ops.py +2 -2
- mindspore/ops/operations/array_ops.py +11 -233
- mindspore/ops/operations/comm_ops.py +32 -32
- mindspore/ops/operations/custom_ops.py +7 -89
- mindspore/ops/operations/manually_defined/ops_def.py +329 -4
- mindspore/ops/operations/math_ops.py +13 -163
- mindspore/ops/operations/nn_ops.py +9 -316
- mindspore/ops/operations/random_ops.py +1 -1
- mindspore/ops/operations/sparse_ops.py +3 -3
- mindspore/ops/primitive.py +2 -2
- mindspore/ops_generate/arg_dtype_cast.py +12 -3
- mindspore/ops_generate/arg_handler.py +24 -0
- mindspore/ops_generate/gen_ops_inner_prim.py +2 -0
- mindspore/ops_generate/gen_pyboost_func.py +13 -6
- mindspore/ops_generate/pyboost_utils.py +2 -17
- mindspore/parallel/__init__.py +3 -2
- mindspore/parallel/_auto_parallel_context.py +106 -1
- mindspore/parallel/_parallel_serialization.py +34 -2
- mindspore/parallel/_utils.py +16 -0
- mindspore/parallel/algo_parameter_config.py +4 -4
- mindspore/parallel/checkpoint_transform.py +249 -77
- mindspore/parallel/cluster/process_entity/_api.py +1 -1
- mindspore/parallel/parameter_broadcast.py +1 -1
- mindspore/parallel/shard.py +1 -1
- mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +1 -0
- mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +17 -5
- mindspore/profiler/parser/ascend_msprof_exporter.py +3 -3
- mindspore/profiler/parser/ascend_msprof_generator.py +10 -3
- mindspore/profiler/parser/ascend_op_generator.py +26 -9
- mindspore/profiler/parser/ascend_timeline_generator.py +7 -4
- mindspore/profiler/parser/profiler_info.py +11 -1
- mindspore/profiler/profiling.py +13 -5
- mindspore/rewrite/api/node.py +12 -12
- mindspore/rewrite/api/symbol_tree.py +11 -11
- mindspore/run_check/_check_version.py +1 -1
- mindspore/safeguard/rewrite_obfuscation.py +2 -2
- mindspore/train/amp.py +4 -4
- mindspore/train/anf_ir_pb2.py +8 -2
- mindspore/train/callback/_backup_and_restore.py +2 -2
- mindspore/train/callback/_callback.py +4 -4
- mindspore/train/callback/_checkpoint.py +2 -2
- mindspore/train/callback/_early_stop.py +2 -2
- mindspore/train/callback/_landscape.py +4 -4
- mindspore/train/callback/_loss_monitor.py +2 -2
- mindspore/train/callback/_on_request_exit.py +2 -2
- mindspore/train/callback/_reduce_lr_on_plateau.py +2 -2
- mindspore/train/callback/_summary_collector.py +2 -2
- mindspore/train/callback/_time_monitor.py +2 -2
- mindspore/train/dataset_helper.py +8 -3
- mindspore/train/loss_scale_manager.py +2 -2
- mindspore/train/metrics/metric.py +3 -3
- mindspore/train/mind_ir_pb2.py +22 -17
- mindspore/train/model.py +15 -15
- mindspore/train/serialization.py +18 -18
- mindspore/train/summary/summary_record.py +7 -7
- mindspore/train/train_thor/convert_utils.py +3 -3
- mindspore/version.py +1 -1
- {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/METADATA +1 -1
- {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/RECORD +226 -212
- {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/WHEEL +0 -0
- {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/entry_points.txt +0 -0
- {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/top_level.txt +0 -0
|
@@ -30,11 +30,14 @@ from mindspore.ops.primitive import Primitive
|
|
|
30
30
|
from mindspore.ops.primitive import PrimitiveWithInfer
|
|
31
31
|
from mindspore.ops.primitive import PrimitiveWithCheck
|
|
32
32
|
from mindspore.ops.primitive import prim_attr_register
|
|
33
|
-
from ..auto_generate import (CeLU, Flatten, LogSoftmax, ReLU, ReLU6,
|
|
34
|
-
Elu, Sigmoid, Softmax, HSwish, HSigmoid, AvgPool, BiasAdd,
|
|
33
|
+
from ..auto_generate import (CeLU, Flatten, LogSoftmax, ReLU, ReLU6, Dense,
|
|
34
|
+
Elu, Sigmoid, Softmax, SoftplusExt, HSwish, HSigmoid, AvgPool, BiasAdd,
|
|
35
35
|
NLLLoss, OneHot, GeLU, FastGeLU, PReLU,
|
|
36
|
-
GridSampler3D, GridSampler2D, LayerNorm, HShrink, AdamWeightDecay, Dropout,
|
|
37
|
-
ApplyRotaryPosEmb, PagedAttention, PagedAttentionMask, ReshapeAndCache
|
|
36
|
+
GridSampler3D, GridSampler2D, LayerNorm, LayerNormExt, HShrink, AdamWeightDecay, Dropout,
|
|
37
|
+
ApplyRotaryPosEmb, PagedAttention, PagedAttentionMask, ReshapeAndCache,
|
|
38
|
+
FlashAttentionScore, Embedding, UpsampleNearest1D, UpsampleNearest2D,
|
|
39
|
+
UpsampleNearest3D, UpsampleTrilinear3D,
|
|
40
|
+
UpsampleBilinear2D, UpsampleLinear1D)
|
|
38
41
|
from .manually_defined import BatchNorm
|
|
39
42
|
|
|
40
43
|
|
|
@@ -449,7 +452,7 @@ class ReLUV3(Primitive):
|
|
|
449
452
|
Inputs:
|
|
450
453
|
- **input_x** (Tensor) - Tensor of shape :math:`(N, *)`, where :math:`*` means, any number of
|
|
451
454
|
additional dimensions, data type is
|
|
452
|
-
`number <https://www.mindspore.cn/docs/en/
|
|
455
|
+
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
|
453
456
|
|
|
454
457
|
Outputs:
|
|
455
458
|
Tensor of shape :math:`(N, *)`, with the same type and shape as the `input_x`.
|
|
@@ -3038,84 +3041,6 @@ class L2Normalize(Primitive):
|
|
|
3038
3041
|
self.axis = axis
|
|
3039
3042
|
|
|
3040
3043
|
|
|
3041
|
-
class UpsampleTrilinear3D(Primitive):
|
|
3042
|
-
r"""
|
|
3043
|
-
Performs upsampling with trilinear interpolation across 3dims for 5dim input Tensor.
|
|
3044
|
-
|
|
3045
|
-
This operator scale up the volumetric input with specified `output_size` or `scales` factors,
|
|
3046
|
-
using trilinear upscaling algorithm.
|
|
3047
|
-
|
|
3048
|
-
Note:
|
|
3049
|
-
One of `scales` and `output_size` must be specified. And it is an error if both are specified.
|
|
3050
|
-
|
|
3051
|
-
Args:
|
|
3052
|
-
align_corners (bool, optional): An optional bool. Default: ``False``.
|
|
3053
|
-
If ``True``, the input and output tensors are aligned by the center points of their corner pixels,
|
|
3054
|
-
preserving the values at the corner pixels.
|
|
3055
|
-
If ``False`` , the input and output tensors are aligned by the corner points of their corner pixels,
|
|
3056
|
-
and the interpolation use edge value padding for out of boundary values.
|
|
3057
|
-
|
|
3058
|
-
Inputs:
|
|
3059
|
-
- **x** (Tensor) - 5D tensor of shape :math:`(N, C, D_{in}, H_{in}, W_{in})`. Supporting types:
|
|
3060
|
-
[float16, float32, float64].
|
|
3061
|
-
- **output_size** (Union[tuple[int], list[int]]): A tuple or list of 3 int elements
|
|
3062
|
-
:math:`(output\_depth, output\_height, output\_width)`. Default: ``None``.
|
|
3063
|
-
- **scales** (Union[tuple[float], list[float]]): A tuple or list of 3 float
|
|
3064
|
-
elements :math:`(scale\_depth, scale\_height, scale\_width)`. Default: ``None``.
|
|
3065
|
-
|
|
3066
|
-
Outputs:
|
|
3067
|
-
- **y** (Tensor) - Upsampled output with the same data type as `x`, whose shape is
|
|
3068
|
-
:math:`(N, C, D_{out}, H_{out}, W_{out})`.
|
|
3069
|
-
|
|
3070
|
-
Raises:
|
|
3071
|
-
TypeError: When `output_size` is not ``None`` and `output_size` is not list[int] or tuple[int].
|
|
3072
|
-
TypeError: When `scales` is not ``None`` and `scales` is not list[float] or tuple[float].
|
|
3073
|
-
TypeError: If dtype of `x` is not in [float16, float32, float64].
|
|
3074
|
-
TypeError: If type of `align_corners` is not bool.
|
|
3075
|
-
ValueError: If any value of `output_size` is negative or zero when `output_size` is not ``None``.
|
|
3076
|
-
ValueError: If any value of `scales` is negative or zero when `scales` is not ``None``.
|
|
3077
|
-
ValueError: If shape of `x` is not 5D.
|
|
3078
|
-
ValueError: If none of `scales` and `output_size` is specified or both specified.
|
|
3079
|
-
ValueError: If size of `scales` is not equal 3 when `scales` is specified.
|
|
3080
|
-
ValueError: If size of `output_size` is not equal 3 when `output_size` is specified.
|
|
3081
|
-
|
|
3082
|
-
Supported Platforms:
|
|
3083
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
3084
|
-
|
|
3085
|
-
Examples:
|
|
3086
|
-
>>> import numpy as np
|
|
3087
|
-
>>> from mindspore import Tensor, ops
|
|
3088
|
-
>>> net = ops.UpsampleTrilinear3D()
|
|
3089
|
-
>>> in_x = Tensor(input_data=np.random.randn(2, 3, 4, 512, 256))
|
|
3090
|
-
>>> output_size=[4, 64, 48]
|
|
3091
|
-
>>> out = net(in_x, output_size, None)
|
|
3092
|
-
>>> print(out.shape)
|
|
3093
|
-
(2, 3, 4, 64, 48)
|
|
3094
|
-
>>>
|
|
3095
|
-
>>> net = ops.UpsampleTrilinear3D()
|
|
3096
|
-
>>> in_x = Tensor(np.arange(1, 5, dtype=np.float32).reshape((1, 1, 1, 2, 2)))
|
|
3097
|
-
>>> output_size=[2, 4, 4]
|
|
3098
|
-
>>> out = net(in_x, output_size, None)
|
|
3099
|
-
>>> print(out)
|
|
3100
|
-
[[[[[1. 1.25 1.75 2. ]
|
|
3101
|
-
[1.5 1.75 2.25 2.5 ]
|
|
3102
|
-
[2.5 2.75 3.25 3.5 ]
|
|
3103
|
-
[3. 3.25 3.75 4. ]]
|
|
3104
|
-
[[1. 1.25 1.75 2. ]
|
|
3105
|
-
[1.5 1.75 2.25 2.5 ]
|
|
3106
|
-
[2.5 2.75 3.25 3.5 ]
|
|
3107
|
-
[3. 3.25 3.75 4. ]]]]]
|
|
3108
|
-
"""
|
|
3109
|
-
|
|
3110
|
-
@prim_attr_register
|
|
3111
|
-
def __init__(self, align_corners=False):
|
|
3112
|
-
"""Initialize UpsampleTrilinear3D."""
|
|
3113
|
-
self.init_prim_io_names(inputs=['x', 'output_size', 'scales'], outputs=['y'])
|
|
3114
|
-
self.align_corners = align_corners
|
|
3115
|
-
validator.check_bool(self.align_corners, "align_corners", self.name)
|
|
3116
|
-
self.add_prim_attr('align_corners', self.align_corners)
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
3044
|
class GetNext(Primitive):
|
|
3120
3045
|
"""
|
|
3121
3046
|
Returns the next element in the dataset queue.
|
|
@@ -6378,6 +6303,7 @@ class DynamicRNN(Primitive):
|
|
|
6378
6303
|
self.forget_bias = validator.check_value_type("forget_bias", forget_bias, [float], self.name)
|
|
6379
6304
|
self.use_peephole = validator.check_value_type("use_peephole", use_peephole, [bool], self.name)
|
|
6380
6305
|
self.time_major = validator.check_value_type("time_major", time_major, [bool], self.name)
|
|
6306
|
+
validator.check("time_major", time_major, "the supported value", True, validator.EQ, self.name)
|
|
6381
6307
|
self.is_training = validator.check_value_type("is_training", is_training, [bool], self.name)
|
|
6382
6308
|
validator.check_value_type("cell_type", cell_type, [str], self.name)
|
|
6383
6309
|
self.cell_type = validator.check_string(cell_type, ['LSTM'], "cell_type", self.name)
|
|
@@ -9090,71 +9016,6 @@ class Pdist(Primitive):
|
|
|
9090
9016
|
self.init_prim_io_names(inputs=['x'], outputs=['y'])
|
|
9091
9017
|
|
|
9092
9018
|
|
|
9093
|
-
class UpsampleNearest3D(Primitive):
|
|
9094
|
-
r"""
|
|
9095
|
-
Performs nearest neighbor upsampling operation.
|
|
9096
|
-
|
|
9097
|
-
This operator scale up the volumetric input with specified `output_size` or `scales` factors, using nearest
|
|
9098
|
-
neighbor algorithm.
|
|
9099
|
-
|
|
9100
|
-
One of `output_size` or `scales` must be given, and can not specified both at the same time.
|
|
9101
|
-
|
|
9102
|
-
Inputs:
|
|
9103
|
-
- **x** (Tensor) - 5D tensor of shape :math:`(N, C, D_{in}, H_{in}, W_{in})`.
|
|
9104
|
-
Supporting types: [float16, float32, float64].
|
|
9105
|
-
- **output_size** (Union[tuple[int], list[int]]): A tuple or list of int specifying the output volumetric size.
|
|
9106
|
-
Default: ``None``.
|
|
9107
|
-
- **scales** (Union[tuple[float], list[float]]): A tuple or list of float specifying the upsampling factors.
|
|
9108
|
-
Default: ``None``.
|
|
9109
|
-
|
|
9110
|
-
Outputs:
|
|
9111
|
-
- **y** (Tensor) - Upsampled output with the same type as `x` , whose shape is
|
|
9112
|
-
:math:`(N, C, D_{out}, H_{out}, W_{out})`.
|
|
9113
|
-
|
|
9114
|
-
Raises:
|
|
9115
|
-
TypeError: When `output_size` is not ``None`` and `output_size` is not list[int] or tuple[int].
|
|
9116
|
-
TypeError: When `scales` is not ``None`` and `scales` is not list[float] or tuple[float].
|
|
9117
|
-
TypeError: If dtype of `x` is not int [uint8, float16, float32, float64].
|
|
9118
|
-
ValueError: If any value of `output_size` is negative or zero when `output_size` is not ``None``.
|
|
9119
|
-
ValueError: If any value of `scales` is negative or zero when `scales` is not ``None``.
|
|
9120
|
-
ValueError: If shape of `x` is not 5D.
|
|
9121
|
-
ValueError: If none of `scales` and `output_size` is specified or both specified.
|
|
9122
|
-
ValueError: If size of `scales` is not equal 3 when `scales` is specified.
|
|
9123
|
-
ValueError: If size of `output_size` is not equal 3 when `output_size` is specified.
|
|
9124
|
-
|
|
9125
|
-
Supported Platforms:
|
|
9126
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
9127
|
-
|
|
9128
|
-
Examples:
|
|
9129
|
-
>>> import numpy as np
|
|
9130
|
-
>>> from mindspore import Tensor, ops
|
|
9131
|
-
>>> from mindspore import dtype as mstype
|
|
9132
|
-
>>> x = Tensor(np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
|
|
9133
|
-
... .reshape([1, 1, 2, 2, 4]), mstype.float32)
|
|
9134
|
-
>>> output_size = [3, 4, 5]
|
|
9135
|
-
>>> net = ops.UpsampleNearest3D()
|
|
9136
|
-
>>> output = net(x, output_size, None)
|
|
9137
|
-
>>> print(output)
|
|
9138
|
-
[[[[[ 1. 1. 2. 3. 4.]
|
|
9139
|
-
[ 1. 1. 2. 3. 4.]
|
|
9140
|
-
[ 5. 5. 6. 7. 8.]
|
|
9141
|
-
[ 5. 5. 6. 7. 8.]]
|
|
9142
|
-
[[ 1. 1. 2. 3. 4.]
|
|
9143
|
-
[ 1. 1. 2. 3. 4.]
|
|
9144
|
-
[ 5. 5. 6. 7. 8.]
|
|
9145
|
-
[ 5. 5. 6. 7. 8.]]
|
|
9146
|
-
[[ 9. 9. 10. 11. 12.]
|
|
9147
|
-
[ 9. 9. 10. 11. 12.]
|
|
9148
|
-
[13. 13. 14. 15. 16.]
|
|
9149
|
-
[13. 13. 14. 15. 16.]]]]]
|
|
9150
|
-
"""
|
|
9151
|
-
|
|
9152
|
-
@prim_attr_register
|
|
9153
|
-
def __init__(self):
|
|
9154
|
-
"""Initialize UpsampleNearest3D."""
|
|
9155
|
-
self.init_prim_io_names(inputs=['x', 'output_size', 'scales'], outputs=['y'])
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
9019
|
class SparseApplyAdagradDA(Primitive):
|
|
9159
9020
|
r"""
|
|
9160
9021
|
Update `var` according to the proximal adagrad scheme.
|
|
@@ -9797,54 +9658,6 @@ class MaxPoolWithArgmaxV2(Primitive):
|
|
|
9797
9658
|
self.add_prim_attr("ceil_mode", self.ceil_mode)
|
|
9798
9659
|
|
|
9799
9660
|
|
|
9800
|
-
class Dense(Primitive):
|
|
9801
|
-
r"""
|
|
9802
|
-
The dense connected fusion operator.
|
|
9803
|
-
|
|
9804
|
-
Applies dense connected operator for the input. The implement of the operation is as:
|
|
9805
|
-
|
|
9806
|
-
.. math::
|
|
9807
|
-
output = x @ w ^ T + b,
|
|
9808
|
-
|
|
9809
|
-
where :math:`x` is the input tensor, :math:`w` is a weight matrix with the same data type as the :math:`x` ,
|
|
9810
|
-
and :math:`b` is a bias vector with the same data type as the :math:`x` (only if `b` is not ``None``).
|
|
9811
|
-
|
|
9812
|
-
Inputs:
|
|
9813
|
-
- **x** (Tensor) - The shape must meet the following requirement: :math:`len(x.shape)>0`.
|
|
9814
|
-
- **w** (Tensor) - The shape must meet the following requirements:
|
|
9815
|
-
If :math:`len(x.shape)>1`, :math:`len(w.shape)=2`. If :math:`len(x.shape)=1`, :math:`len(w.shape)=1`.
|
|
9816
|
-
:math:`w.shape[-1]=x.shape[-1]`.
|
|
9817
|
-
- **b** (Union[Tensor, None]) - If `b` is not ``None``, the shape must meet the following requirements:
|
|
9818
|
-
If :math:`len(x.shape)>1`, :math:`len(b.shape)=0` or :math:`len(b.shape)=1` .
|
|
9819
|
-
If :math:`len(b.shape)=1`, :math:`b.shape[0]=w.shape[0]`.
|
|
9820
|
-
If :math:`len(x.shape)=1`, :math:`len(b.shape)=0`.
|
|
9821
|
-
|
|
9822
|
-
Outputs:
|
|
9823
|
-
If :math:`len(x.shape)>1`, Tensor of shape :math:`(*x.shape[:-1], w.shape[0])`.
|
|
9824
|
-
If :math:`len(x.shape)=1`, Tensor of shape :math:`()`.
|
|
9825
|
-
|
|
9826
|
-
Supported Platforms:
|
|
9827
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
9828
|
-
|
|
9829
|
-
Examples:
|
|
9830
|
-
>>> import numpy as np
|
|
9831
|
-
>>> from mindspore import Tensor, ops
|
|
9832
|
-
>>> x = Tensor(np.random.random((4, 5, 6, 7)).astype(np.float32))
|
|
9833
|
-
>>> weight = Tensor(np.random.random((6, 7)).astype(np.float32))
|
|
9834
|
-
>>> bias = Tensor(np.random.random((6,)).astype(np.float32))
|
|
9835
|
-
>>> dense = ops.Dense()
|
|
9836
|
-
>>> output = dense(x, weight, bias)
|
|
9837
|
-
>>> print(output.shape)
|
|
9838
|
-
(4, 5, 6, 6)
|
|
9839
|
-
"""
|
|
9840
|
-
|
|
9841
|
-
@prim_attr_register
|
|
9842
|
-
def __init__(self):
|
|
9843
|
-
"""Initialize Dense."""
|
|
9844
|
-
self.init_prim_io_names(inputs=['x', 'w', 'b'], outputs=["output"])
|
|
9845
|
-
self.add_prim_attr("has_bias", True)
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
9661
|
class WKV(Primitive):
|
|
9849
9662
|
r"""
|
|
9850
9663
|
The WKV computation is similar to AFT(Zhai et al., 2021), but W is now a channel-wise vector multiplied
|
|
@@ -10052,115 +9865,6 @@ class IncreFlashAttention(Primitive):
|
|
|
10052
9865
|
outputs=["attention_out"])
|
|
10053
9866
|
|
|
10054
9867
|
|
|
10055
|
-
class FlashAttentionScore(Primitive):
|
|
10056
|
-
r"""
|
|
10057
|
-
FlashAttentionScore.
|
|
10058
|
-
.. math::
|
|
10059
|
-
\begin{array}{ll} \\
|
|
10060
|
-
y = Dropout(Softmax(Mask(scale_value \mul (real_shift + query * key), attn_mask), -1), keep_prob) \\
|
|
10061
|
-
\mul value \\
|
|
10062
|
-
\end{array}
|
|
10063
|
-
|
|
10064
|
-
.. warning::
|
|
10065
|
-
This is an experimental API that is subject to change or deletion.
|
|
10066
|
-
B -- Batch size
|
|
10067
|
-
S1 -- Sequence length of query. The value ranges from 1 to 32768 and is a multiple of 16.
|
|
10068
|
-
S2 -- Sequence length of key and value. The value ranges from 1 to 32768 and is a multiple of 16.
|
|
10069
|
-
N1 -- Num heads of query
|
|
10070
|
-
N2 -- Num heads of key and value, and N2 must be a factor of N1
|
|
10071
|
-
D -- Head size. Support value: 64, 80, 96, 120, 128 and 256.
|
|
10072
|
-
H1 -- Hidden size of query, which equals to N1 * D
|
|
10073
|
-
H2 -- Hidden size of key and value, which equals to N2 * D
|
|
10074
|
-
Args:
|
|
10075
|
-
head_num (int): The head num of query. Default: 1.
|
|
10076
|
-
keep_prob (float): The keep probability of dropout. Default: 1.0.
|
|
10077
|
-
scale_value (float): The scale factor of score. Default: 1.0.
|
|
10078
|
-
pre_tokens (int): Parameter for sparse computation, represents how many tokens are counted forward.
|
|
10079
|
-
When sparse_mode is set to 1, 2, 3, or 5, this parameter does not take effect. Default: 2147483647.
|
|
10080
|
-
next_tokens (int): Parameter for sparse computation, represents how many tokens are counted backward.
|
|
10081
|
-
When sparse_mode is set to 1, 2, 3, or 5, this parameter does not take effect. Default: 2147483647.
|
|
10082
|
-
inner_precise (int): The parameter is reserved and not implemented yet. Default: 0.
|
|
10083
|
-
input_layout (str): Specifies the layout of input `query`, key and value. The value can be "BSH" or "BNSD".
|
|
10084
|
-
Default: "BSH".
|
|
10085
|
-
sparse_mode (int): Indicates sparse mode. Default 0.
|
|
10086
|
-
|
|
10087
|
-
- 0: Indicates the defaultMask mode. If attn_mask is not passed, the mask operation is not performed,
|
|
10088
|
-
and preTokens and nextTokens(internally assigned as INT_MAX) are ignored. If passed in, the full attn_mask
|
|
10089
|
-
matrix (S1 * S2) needs to be passed in, indicating that the part between preTokens and nextTokens needs to
|
|
10090
|
-
be calculated.
|
|
10091
|
-
- 1: Represents allMask, that is, passing in the complete attn_mask matrix.
|
|
10092
|
-
- 2: Representing the leftUpCausal mode corresponds to the lower triangle scenario divided by the left
|
|
10093
|
-
vertex, and the optimized attn_mask matrix (2048*2048) is required.
|
|
10094
|
-
- 3: Representing the rightDownCausal model corresponds to the lower triangle scene divided by the lower
|
|
10095
|
-
right vertex, and the optimized attn_mask matrix (2048*2048) is required.
|
|
10096
|
-
- 4: Represents the band scenario, that is, the part between counting preTokens and nextTokens, and the
|
|
10097
|
-
optimized attn_mask matrix (2048*2048) is required..
|
|
10098
|
-
- 5: Represents the prefix scenario, that is, on the basis of rightDownCasual, a matrix with length S1 and
|
|
10099
|
-
width N is added to the left side. The value of N is obtained by the new input prefix, and the N value of
|
|
10100
|
-
each Batch axis is different. Not implemented yet.
|
|
10101
|
-
- 6: Represents the global scenario, not implemented yet.
|
|
10102
|
-
- 7: Represents the dilated scenario, not implemented yet.
|
|
10103
|
-
- 8: Represents the block_local scenario, not implemented yet.
|
|
10104
|
-
|
|
10105
|
-
Inputs:
|
|
10106
|
-
- **query** (Tensor[float16, bfloat16]) - The query tensor.
|
|
10107
|
-
Input tensor of shape :math:`(B, S1, H1)` or `(B, N1, S1, D)`.
|
|
10108
|
-
- **key** (Tensor[float16, bfloat16]) - The key tensor.
|
|
10109
|
-
Input tensor of shape :math:`(B, S2, H2)` or `(B, N2, S2, D)`.
|
|
10110
|
-
- **value** (Tensor[float16, bfloat16]) - The value tensor.
|
|
10111
|
-
Input tensor of shape :math:`(B, S2, H2)` or `(B, N2, S2, D)`.
|
|
10112
|
-
- **real_shift** (Union[Tensor[float16, bfloat16], None]) - The position embedding code. If S is greater than
|
|
10113
|
-
1024 and the mask of the lower triangle is used, enter only the inverse 1024 lines of the lower triangle for
|
|
10114
|
-
memory optimization.
|
|
10115
|
-
Input tensor of shape :math: `(B, N1, S1, S2)`, `(1, N1, S1, S2)`, `(B, N1, 1024, S2)`, `(1, N1, 1024, S2)`
|
|
10116
|
-
or (1024, 1024).
|
|
10117
|
-
- **drop_mask** (Union[Tensor[uint8], None]) - The dropout mask tensor.
|
|
10118
|
-
Input tensor of shape :math:`(B, N1, S1, S2 // 8) or None`.
|
|
10119
|
-
- **padding_mask** (None) - Reserved parameter. Not implemented yet.
|
|
10120
|
-
- **attn_mask** (Union[Tensor[uint8], None]) - The attention mask tensor. For each element, 0 indicates
|
|
10121
|
-
retention and 1 indicates discard. Input tensor of shape :math:`(B, N1, S1, S2)`, `(B, 1, S1, S2)`, `(S1, S2)`
|
|
10122
|
-
or (2048, 2048).
|
|
10123
|
-
- **prefix** (Union[Tensor[int64], None]) - N value of each Batch in the prefix sparse calculation scenario.
|
|
10124
|
-
Input tensor of shape :math:`(B,)`.
|
|
10125
|
-
|
|
10126
|
-
Outputs:
|
|
10127
|
-
- **softmax_max** (Tensor[float32]) - (B, N1, S1, 8)
|
|
10128
|
-
- **softmax_sum** (Tensor[float32]) - (B, N1, S1, 8)
|
|
10129
|
-
- **softmax_out** (Tensor[float16, bfloat16]) - Useless output, ignore it. Output tensor of shape : `()`
|
|
10130
|
-
- **attention_out** (Tensor[float16, bfloat16]) - The output of attention, its shape, and data type
|
|
10131
|
-
are the same as the query.
|
|
10132
|
-
|
|
10133
|
-
Supported Platforms:
|
|
10134
|
-
``Ascend910B``
|
|
10135
|
-
"""
|
|
10136
|
-
|
|
10137
|
-
@prim_attr_register
|
|
10138
|
-
def __init__(self, head_num=1, keep_prob=1.0, scale_value=1.0, pre_tokens=2147483647, next_tokens=2147483647,
|
|
10139
|
-
inner_precise=0, input_layout="BSH", sparse_mode=0):
|
|
10140
|
-
"""Initialize FlashAttentionScore"""
|
|
10141
|
-
validator.check_value_type('head_num', head_num, [int], self.name)
|
|
10142
|
-
validator.check_value_type('keep_prob', keep_prob, [int, float], self.name)
|
|
10143
|
-
validator.check_float(keep_prob, 0.0, validator.GE, "keep_prob", self.name)
|
|
10144
|
-
validator.check_float(keep_prob, 1.0, validator.LE, "keep_prob", self.name)
|
|
10145
|
-
validator.check_value_type('scale_value', scale_value, [float], self.name)
|
|
10146
|
-
validator.check_value_type('pre_tokens', pre_tokens, [int], self.name)
|
|
10147
|
-
validator.check_value_type('next_tokens', next_tokens, [int], self.name)
|
|
10148
|
-
validator.check_value_type('inner_precise', inner_precise, [int], self.name)
|
|
10149
|
-
validator.check_value_type('sparse_mode', sparse_mode, [int], self.name)
|
|
10150
|
-
valid_sparse_mode = [0, 1, 2, 3, 4]
|
|
10151
|
-
if sparse_mode not in valid_sparse_mode:
|
|
10152
|
-
raise ValueError(f"Attribute 'sparse_mode' must be one of {valid_sparse_mode}, but got {sparse_mode}")
|
|
10153
|
-
if inner_precise not in [0]:
|
|
10154
|
-
raise ValueError(f"Attribute 'inner_precise' must be 0, but got {inner_precise}")
|
|
10155
|
-
validator.check_value_type('input_layout', input_layout, [str], self.name)
|
|
10156
|
-
support_layout = ["BSH", "BNSD"]
|
|
10157
|
-
if input_layout not in support_layout:
|
|
10158
|
-
raise ValueError(f"Attribute 'input_layout' must be one of {support_layout}, but got {input_layout}")
|
|
10159
|
-
self.init_prim_io_names(
|
|
10160
|
-
inputs=['query', 'key', 'value', 'real_shift', 'drop_mask', 'padding_mask', 'attn_mask', 'prefix'],
|
|
10161
|
-
outputs=['softmax_max', 'softmax_sum', 'softmax_out', 'attention_out'])
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
9868
|
class RmsNorm(Primitive):
|
|
10165
9869
|
r"""
|
|
10166
9870
|
The RmsNorm operator is a normalization operation, and its formula is:
|
|
@@ -10196,14 +9900,3 @@ class RmsNorm(Primitive):
|
|
|
10196
9900
|
"""Initialize Dense."""
|
|
10197
9901
|
validator.check_value_type("epsilon", epsilon, [float], self.name)
|
|
10198
9902
|
self.init_prim_io_names(inputs=['x', 'gamma'], outputs=["y", "rstd"])
|
|
10199
|
-
|
|
10200
|
-
|
|
10201
|
-
class MatmulQkv(Primitive):
|
|
10202
|
-
r"""
|
|
10203
|
-
Fuse three matmul ops for q k v attention into one
|
|
10204
|
-
"""
|
|
10205
|
-
@prim_attr_register
|
|
10206
|
-
def __init__(self):
|
|
10207
|
-
"""Initialize"""
|
|
10208
|
-
self.init_prim_io_names(inputs=['hidden_states', 'weight_q', 'weight_k', 'weight_v'],
|
|
10209
|
-
outputs=["output_q", "output_k", "output_v"])
|
|
@@ -20,7 +20,7 @@ from mindspore import _checkparam as Validator
|
|
|
20
20
|
from mindspore.common import dtype as mstype
|
|
21
21
|
from mindspore.ops.primitive import PrimitiveWithInfer, prim_attr_register, Primitive
|
|
22
22
|
from mindspore.ops._utils import get_broadcast_shape
|
|
23
|
-
from ..auto_generate import RandpermV2
|
|
23
|
+
from ..auto_generate import RandpermV2, UniformExt
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class NonDeterministicInts(Primitive):
|
|
@@ -60,7 +60,7 @@ class SparseDenseCwiseAdd(Primitive):
|
|
|
60
60
|
``Ascend`` ``GPU`` ``CPU``
|
|
61
61
|
|
|
62
62
|
Examples:
|
|
63
|
-
>>> from mindspore
|
|
63
|
+
>>> from mindspore import Tensor
|
|
64
64
|
>>> from mindspore.common import dtype as ms
|
|
65
65
|
>>> from mindspore.ops.operations import sparse_ops as ops
|
|
66
66
|
>>> x1_indices = Tensor([[0, 0], [2, 2]], dtype=ms.int64)
|
|
@@ -115,7 +115,7 @@ class SparseDenseCwiseMul(Primitive):
|
|
|
115
115
|
``Ascend`` ``GPU`` ``CPU``
|
|
116
116
|
|
|
117
117
|
Examples:
|
|
118
|
-
>>> from mindspore
|
|
118
|
+
>>> from mindspore import Tensor
|
|
119
119
|
>>> from mindspore.common import dtype as ms
|
|
120
120
|
>>> from mindspore.ops.operations import sparse_ops as ops
|
|
121
121
|
>>> x1_indices = Tensor([[0, 0], [2, 2]], dtype=ms.int64)
|
|
@@ -170,7 +170,7 @@ class SparseDenseCwiseDiv(Primitive):
|
|
|
170
170
|
``Ascend`` ``GPU``
|
|
171
171
|
|
|
172
172
|
Examples:
|
|
173
|
-
>>> from mindspore
|
|
173
|
+
>>> from mindspore import Tensor
|
|
174
174
|
>>> from mindspore.common import dtype as ms
|
|
175
175
|
>>> from mindspore.ops.operations import sparse_ops as ops
|
|
176
176
|
>>> x1_indices = Tensor([[0, 0], [2, 2]], dtype=ms.int64)
|
mindspore/ops/primitive.py
CHANGED
|
@@ -548,7 +548,7 @@ class PrimitiveWithCheck(Primitive):
|
|
|
548
548
|
the shape and type. Method infer_value() can also be defined (such as PrimitiveWithInfer) for constant propagation.
|
|
549
549
|
|
|
550
550
|
More on how to customize a Op, please refer to `Custom Operators
|
|
551
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
551
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/operation/op_custom.html>`_.
|
|
552
552
|
|
|
553
553
|
Args:
|
|
554
554
|
name (str): Name of the current Primitive.
|
|
@@ -642,7 +642,7 @@ class PrimitiveWithInfer(Primitive):
|
|
|
642
642
|
logic of the shape and type. The infer_value() is used for constant propagation.
|
|
643
643
|
|
|
644
644
|
More on how to customize a Op, please refer to `Custom Operators
|
|
645
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
645
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/operation/op_custom.html>`_.
|
|
646
646
|
|
|
647
647
|
Args:
|
|
648
648
|
name (str): Name of the current Primitive.
|
|
@@ -20,17 +20,25 @@ import mindspore as ms
|
|
|
20
20
|
from mindspore import ops
|
|
21
21
|
from mindspore.common.tensor import Tensor
|
|
22
22
|
from mindspore.ops.operations._sequence_ops import TensorToScalar, TensorToTuple
|
|
23
|
-
from mindspore.ops_generate.gen_ops_inner_prim import
|
|
23
|
+
from mindspore.ops_generate.gen_ops_inner_prim import TupleToList
|
|
24
24
|
from mindspore._c_expression import OpDtype
|
|
25
25
|
|
|
26
26
|
tensor_to_tuple_ = TensorToTuple()
|
|
27
|
-
list_to_tuple = ListToTuple()
|
|
28
27
|
tuple_to_list = TupleToList()
|
|
29
28
|
|
|
29
|
+
|
|
30
30
|
def int_to_float(data):
|
|
31
31
|
return float(data)
|
|
32
32
|
|
|
33
33
|
|
|
34
|
+
def list_to_tuple(data):
|
|
35
|
+
# tuple() currently does not support Any from JIT Fallback.
|
|
36
|
+
res = ()
|
|
37
|
+
for element in data:
|
|
38
|
+
res += (element,)
|
|
39
|
+
return res
|
|
40
|
+
|
|
41
|
+
|
|
34
42
|
def scalar_to_tuple(data):
|
|
35
43
|
return (data,)
|
|
36
44
|
|
|
@@ -61,6 +69,7 @@ def tuple_to_tensor(data):
|
|
|
61
69
|
def list_to_tensor(data):
|
|
62
70
|
return ops.tuple_to_array(list_to_tuple(data))
|
|
63
71
|
|
|
72
|
+
|
|
64
73
|
# There will be some problems in using OpDtype.xxx directly in GRAPH_MODE, so convert it to int.
|
|
65
74
|
# type
|
|
66
75
|
DT_TYPE_VAL = int(OpDtype.DT_TYPE)
|
|
@@ -243,6 +252,6 @@ def type_it(op_name, arg_name, data, src_type, dst_type):
|
|
|
243
252
|
dst_type = int(dst_type)
|
|
244
253
|
if not is_instance_in(data, src_type) and not is_instance_of(data, dst_type):
|
|
245
254
|
support_list = get_support_dtype_list(src_type, dst_type)
|
|
246
|
-
raise TypeError(f"For '{op_name}', the type of '{arg_name}' should be one of '[{support_list}]', "
|
|
255
|
+
raise TypeError(f"For '{op_name}', the type of '{arg_name}' should be one of '[{support_list}]', "
|
|
247
256
|
f"but got {type(data)}.")
|
|
248
257
|
return do_type_cast(data, dst_type)
|
|
@@ -79,6 +79,30 @@ def to_dilations(op_name, arg_name, dilation):
|
|
|
79
79
|
raise ValueError(arg_invalid_info(op_name, arg_name, dilation))
|
|
80
80
|
|
|
81
81
|
|
|
82
|
+
def to_output_padding(op_name, arg_name, output_padding):
|
|
83
|
+
"""
|
|
84
|
+
convert output_padding: int/tuple[int*4] -> tuple[int*2].
|
|
85
|
+
"""
|
|
86
|
+
if isinstance(output_padding, int):
|
|
87
|
+
return (output_padding, output_padding)
|
|
88
|
+
if isinstance(output_padding, (tuple, list)):
|
|
89
|
+
if len(output_padding) == 4:
|
|
90
|
+
return (output_padding[2], output_padding[3])
|
|
91
|
+
return output_padding
|
|
92
|
+
raise ValueError(arg_invalid_info(op_name, arg_name, output_padding))
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def to_2d_paddings(op_name, arg_name, pad):
|
|
96
|
+
"""
|
|
97
|
+
convert paddings: int -> tuple[int*2].
|
|
98
|
+
"""
|
|
99
|
+
if isinstance(pad, int):
|
|
100
|
+
return (pad,) * 2
|
|
101
|
+
if isinstance(pad, (tuple, list)):
|
|
102
|
+
return pad
|
|
103
|
+
raise ValueError(arg_invalid_info(op_name, arg_name, pad))
|
|
104
|
+
|
|
105
|
+
|
|
82
106
|
def to_paddings(op_name, arg_name, pad):
|
|
83
107
|
"""
|
|
84
108
|
convert paddings: int -> tuple[int*4].
|
|
@@ -68,6 +68,8 @@ class StringToEnum(Primitive):
|
|
|
68
68
|
|
|
69
69
|
def __call__(self, op_name, arg_name, enum_str):
|
|
70
70
|
"""Run in PyNative mode"""
|
|
71
|
+
if enum_str is None:
|
|
72
|
+
return None
|
|
71
73
|
if not isinstance(enum_str, str):
|
|
72
74
|
raise TypeError(f"For '{op_name}', the input '{arg_name}' should be a str, but got {type(enum_str)}.")
|
|
73
75
|
return op_enum.str_to_enum(op_name, arg_name, enum_str)
|
|
@@ -203,10 +203,15 @@ def generate_pyboost_op_source_code(work_path, op_proto, template_paths, convert
|
|
|
203
203
|
customize_include = "#include \"plugin/device/gpu/kernel/pyboost/customize/{}.h\"".format(
|
|
204
204
|
operator_name.lower())
|
|
205
205
|
elif op_proto.is_view:
|
|
206
|
+
set_output_abs = "SetOutputAbstract();"
|
|
207
|
+
if converter.call_func_outputs == "outputs_":
|
|
208
|
+
set_output_abs = "SetOutputTupleAbstract();"
|
|
206
209
|
call_impl = view_tpl.replace(op_name=op_proto.class_name,
|
|
207
210
|
call_args=converter.call_args,
|
|
208
211
|
call_tensors=call_args_tensor,
|
|
209
|
-
|
|
212
|
+
return_values=converter.call_func_outputs,
|
|
213
|
+
input=converter.call_args[0],
|
|
214
|
+
set_output_abs=set_output_abs)
|
|
210
215
|
customize_include = "#include \"mindspore/core/ops/view/{}_strides_calc.h\"".format(proto_operator_name)
|
|
211
216
|
else:
|
|
212
217
|
cast_input_code, real_call_args_tensor = generate_tensor_cpu_cast_input_code(
|
|
@@ -799,17 +804,19 @@ def gen_pyboost_inner_prim(work_path, op_yaml_data):
|
|
|
799
804
|
gen_header += template.PYBOOST_PY_FUNC_IMPORT_HEADEAR.replace(class_name=op_proto.class_name)
|
|
800
805
|
args = operator_data.get('args')
|
|
801
806
|
input_args = []
|
|
807
|
+
processed_args = []
|
|
802
808
|
process_func = ''
|
|
803
809
|
for arg_name, arg_info in args.items():
|
|
804
810
|
arg_handler = arg_info.get('arg_handler')
|
|
805
|
-
|
|
811
|
+
processed_arg = arg_name
|
|
806
812
|
if arg_handler is not None and arg_handler != 'dtype_to_type_id':
|
|
807
813
|
process_func += f"""converted_{arg_name} = {arg_handler}({arg_name})\n"""
|
|
808
|
-
|
|
809
|
-
input_args.append(
|
|
810
|
-
|
|
814
|
+
processed_arg = 'converted_' + arg_name
|
|
815
|
+
input_args.append(arg_name)
|
|
816
|
+
processed_args.append(processed_arg)
|
|
811
817
|
gen_py += template.PYTHON_PRIM_TEMPLATE.replace(class_name=op_proto.class_name, input_args=input_args,
|
|
812
|
-
process_func=process_func, func_impl_name=operator_name
|
|
818
|
+
process_func=process_func, func_impl_name=operator_name,
|
|
819
|
+
processed_args=processed_args)
|
|
813
820
|
dir_path = os.path.join(work_path, "mindspore/python/mindspore/ops/auto_generate")
|
|
814
821
|
pathlib.Path(dir_path).mkdir(parents=True, exist_ok=True)
|
|
815
822
|
dst_file_path = os.path.join(dir_path, "pyboost_inner_prim.py")
|
|
@@ -50,22 +50,7 @@ def get_index(index: int):
|
|
|
50
50
|
:param index:
|
|
51
51
|
:return: str
|
|
52
52
|
"""
|
|
53
|
-
|
|
54
|
-
0: 'kIndex0',
|
|
55
|
-
1: 'kIndex1',
|
|
56
|
-
2: 'kIndex2',
|
|
57
|
-
3: 'kIndex3',
|
|
58
|
-
4: 'kIndex4',
|
|
59
|
-
5: 'kIndex5',
|
|
60
|
-
6: 'kIndex6',
|
|
61
|
-
7: 'kIndex7',
|
|
62
|
-
8: 'kIndex8',
|
|
63
|
-
9: 'kIndex9',
|
|
64
|
-
10: 'kIndex10',
|
|
65
|
-
}
|
|
66
|
-
if index in index_map:
|
|
67
|
-
return index_map[index]
|
|
68
|
-
raise TypeError(f"""Unsupported index {index} for index map.""")
|
|
53
|
+
return "kIndex" + str(index)
|
|
69
54
|
|
|
70
55
|
|
|
71
56
|
def get_convert_type_str(dtype: str, optional):
|
|
@@ -226,7 +211,7 @@ def get_input_dtype(dtype: str, optional):
|
|
|
226
211
|
|
|
227
212
|
|
|
228
213
|
def is_cube(class_name):
|
|
229
|
-
cube_set = {'Bmm', 'Baddbmm', '
|
|
214
|
+
cube_set = {'Bmm', 'Baddbmm', 'MatMulExt', 'Mv'}
|
|
230
215
|
if class_name in cube_set:
|
|
231
216
|
return True
|
|
232
217
|
return False
|
mindspore/parallel/__init__.py
CHANGED
|
@@ -18,10 +18,11 @@ from __future__ import absolute_import
|
|
|
18
18
|
from mindspore.parallel.algo_parameter_config import get_algo_parameters, reset_algo_parameters, \
|
|
19
19
|
set_algo_parameters
|
|
20
20
|
from mindspore.parallel.checkpoint_transform import rank_list_for_transform, transform_checkpoint_by_rank, \
|
|
21
|
-
transform_checkpoints, merge_pipeline_strategys, sync_pipeline_shared_parameters
|
|
21
|
+
transform_checkpoints, merge_pipeline_strategys, sync_pipeline_shared_parameters, \
|
|
22
|
+
load_segmented_checkpoints
|
|
22
23
|
from mindspore.parallel.parameter_broadcast import parameter_broadcast
|
|
23
24
|
from mindspore.parallel.shard import shard, Layout
|
|
24
25
|
|
|
25
26
|
__all__ = ["set_algo_parameters", "reset_algo_parameters", "get_algo_parameters", "rank_list_for_transform",
|
|
26
27
|
"transform_checkpoint_by_rank", "transform_checkpoints", "merge_pipeline_strategys", "shard",
|
|
27
|
-
"sync_pipeline_shared_parameters", "Layout", "parameter_broadcast"]
|
|
28
|
+
"sync_pipeline_shared_parameters", "Layout", "parameter_broadcast", "load_segmented_checkpoints"]
|