mindspore 2.7.0__cp310-cp310-win_amd64.whl → 2.7.0rc1__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/__init__.py +1 -1
- mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +2 -2
- mindspore/_extends/builtin_operations.py +3 -3
- mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
- mindspore/_extends/parse/__init__.py +3 -3
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -0
- mindspore/_extends/parse/parser.py +22 -28
- mindspore/_extends/parse/standard_method.py +1 -15
- mindspore/_extends/pijit/pijit_func_white_list.py +5 -2
- mindspore/_extends/remote/kernel_build_server_ascend.py +75 -0
- mindspore/amp.py +18 -0
- mindspore/avcodec-59.dll +0 -0
- mindspore/avdevice-59.dll +0 -0
- mindspore/avfilter-8.dll +0 -0
- mindspore/avformat-59.dll +0 -0
- mindspore/avutil-57.dll +0 -0
- mindspore/common/__init__.py +12 -18
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +38 -102
- mindspore/common/_utils.py +1 -9
- mindspore/common/api.py +106 -155
- mindspore/common/{dynamic_shape/auto_dynamic_shape.py → auto_dynamic_shape.py} +23 -17
- mindspore/common/dtype.py +57 -98
- mindspore/common/dump.py +1 -1
- mindspore/common/file_system.py +9 -59
- mindspore/common/hook_handle.py +3 -22
- mindspore/common/np_dtype.py +3 -3
- mindspore/common/parameter.py +20 -4
- mindspore/common/recompute.py +4 -2
- mindspore/common/tensor.py +52 -38
- mindspore/communication/_hccl_management.py +297 -0
- mindspore/context.py +21 -15
- mindspore/dataset/__init__.py +1 -1
- mindspore/dataset/audio/transforms.py +1 -1
- mindspore/dataset/core/config.py +1 -35
- mindspore/dataset/engine/datasets.py +315 -330
- mindspore/dataset/engine/datasets_user_defined.py +22 -38
- mindspore/dataset/transforms/c_transforms.py +2 -2
- mindspore/dataset/transforms/transforms.py +3 -3
- mindspore/dataset/vision/__init__.py +1 -1
- mindspore/dataset/vision/py_transforms.py +8 -8
- mindspore/dataset/vision/transforms.py +5 -17
- mindspore/dataset/vision/utils.py +21 -632
- mindspore/device_context/ascend/op_tuning.py +1 -35
- mindspore/dnnl.dll +0 -0
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +0 -3
- mindspore/include/api/cell.h +4 -28
- mindspore/include/api/cfg.h +7 -24
- mindspore/include/api/context.h +0 -1
- mindspore/include/api/delegate.h +2 -0
- mindspore/include/api/dual_abi_helper.h +19 -100
- mindspore/include/api/graph.h +1 -14
- mindspore/include/api/kernel.h +3 -16
- mindspore/include/api/kernel_api.h +1 -9
- mindspore/include/api/metrics/accuracy.h +0 -9
- mindspore/include/api/model.h +1 -5
- mindspore/include/api/model_group.h +0 -4
- mindspore/include/api/model_parallel_runner.h +0 -2
- mindspore/include/api/status.h +10 -48
- mindspore/include/api/types.h +1 -6
- mindspore/include/dataset/constants.h +0 -9
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/cifar10.py +2 -3
- mindspore/mindrecord/tools/cifar10_to_mr.py +5 -5
- mindspore/mindspore_backend_common.dll +0 -0
- mindspore/mindspore_backend_manager.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_cpu_res_manager.dll +0 -0
- mindspore/mindspore_dump.dll +0 -0
- mindspore/mindspore_frontend.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_memory_pool.dll +0 -0
- mindspore/mindspore_ms_backend.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mindspore_ops_host.dll +0 -0
- mindspore/mindspore_ops_kernel_common.dll +0 -0
- mindspore/mindspore_profiler.dll +0 -0
- mindspore/mindspore_pyboost.dll +0 -0
- mindspore/mindspore_pynative.dll +0 -0
- mindspore/mindspore_res_manager.dll +0 -0
- mindspore/mindspore_runtime_pipeline.dll +0 -0
- mindspore/mint/distributed/__init__.py +0 -4
- mindspore/mint/distributed/distributed.py +14 -217
- mindspore/mint/nn/layer/_functions.py +2 -1
- mindspore/mint/nn/layer/conv.py +6 -6
- mindspore/mint/nn/layer/normalization.py +3 -3
- mindspore/nn/cell.py +174 -216
- mindspore/nn/layer/activation.py +2 -4
- mindspore/nn/layer/basic.py +13 -7
- mindspore/nn/layer/image.py +1 -1
- mindspore/nn/optim/adam.py +3 -1
- mindspore/nn/optim/lamb.py +3 -1
- mindspore/nn/optim/tft_wrapper.py +3 -2
- mindspore/nn/probability/distribution/_utils/utils.py +2 -2
- mindspore/nn/wrap/cell_wrapper.py +5 -39
- mindspore/nn/wrap/grad_reducer.py +15 -0
- mindspore/numpy/array_creations.py +2 -2
- mindspore/numpy/utils_const.py +1 -1
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/grad_inner_ops.py +9 -0
- mindspore/ops/_op_impl/cpu/__init__.py +0 -1
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +2 -12
- mindspore/ops/auto_generate/gen_extend_func.py +4 -4
- mindspore/ops/auto_generate/gen_ops_def.py +16 -290
- mindspore/ops/auto_generate/gen_ops_prim.py +76 -563
- mindspore/ops/composite/base.py +1 -1
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
- mindspore/ops/function/__init__.py +0 -1
- mindspore/ops/function/array_func.py +6 -10
- mindspore/ops/function/debug_func.py +2 -4
- mindspore/ops/function/grad/grad_func.py +12 -4
- mindspore/ops/function/math_func.py +32 -44
- mindspore/ops/function/nn_func.py +20 -18
- mindspore/ops/functional.py +1 -2
- mindspore/ops/functional_overload.py +12 -23
- mindspore/ops/operations/_inner_ops.py +12 -11
- mindspore/ops/operations/array_ops.py +50 -4
- mindspore/ops/operations/comm_ops.py +15 -1
- mindspore/ops/operations/custom_ops.py +4 -10
- mindspore/ops/operations/debug_ops.py +6 -6
- mindspore/ops/operations/manually_defined/ops_def.py +12 -12
- mindspore/ops/operations/math_ops.py +5 -5
- mindspore/ops/operations/nn_ops.py +1 -1
- mindspore/ops/primitive.py +10 -3
- mindspore/ops/tensor_method.py +7 -16
- mindspore/ops_generate/pyboost/gen_pyboost_func.py +16 -0
- mindspore/parallel/_auto_parallel_context.py +15 -5
- mindspore/parallel/_parallel_serialization.py +2 -3
- mindspore/parallel/_ps_context.py +2 -2
- mindspore/parallel/_transformer/transformer.py +4 -4
- mindspore/parallel/_utils.py +11 -5
- mindspore/parallel/auto_parallel.py +9 -23
- mindspore/parallel/checkpoint_transform.py +0 -2
- mindspore/parallel/cluster/process_entity/_api.py +1 -4
- mindspore/parallel/cluster/run.py +3 -5
- mindspore/parallel/function/reshard_func.py +5 -6
- mindspore/parallel/nn/parallel_cell_wrapper.py +3 -40
- mindspore/parallel/nn/parallel_grad_reducer.py +8 -0
- mindspore/parallel/shard.py +21 -7
- mindspore/parallel/transform_safetensors.py +4 -10
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +9 -10
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +1 -1
- mindspore/profiler/common/msprof_cmd_tool.py +2 -2
- mindspore/profiler/common/path_manager.py +0 -9
- mindspore/profiler/common/profiler_context.py +2 -25
- mindspore/profiler/common/profiler_meta_data.py +0 -1
- mindspore/profiler/common/profiler_op_analyse.py +6 -10
- mindspore/{ops/_op_impl/cpu/joinedstr_op.py → profiler/common/validator/__init__.py} +1 -15
- mindspore/profiler/common/validator/validate_path.py +84 -0
- mindspore/profiler/dynamic_profiler.py +46 -91
- mindspore/profiler/envprofiler.py +5 -30
- mindspore/profiler/experimental_config.py +1 -16
- mindspore/profiler/platform/cpu_profiler.py +4 -10
- mindspore/profiler/platform/npu_profiler.py +1 -1
- mindspore/profiler/profiler.py +145 -193
- mindspore/profiler/profiler_action_controller.py +1 -1
- mindspore/profiler/profiler_interface.py +2 -2
- mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
- mindspore/runtime/__init__.py +4 -6
- mindspore/runtime/executor.py +0 -27
- mindspore/runtime/memory.py +0 -1
- mindspore/runtime/thread_bind_core.py +1 -1
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +3 -3
- mindspore/train/amp.py +3 -0
- mindspore/train/callback/_callback.py +1 -2
- mindspore/train/callback/_checkpoint.py +8 -1
- mindspore/train/callback/_flops_collector.py +6 -10
- mindspore/train/callback/_train_fault_tolerance.py +7 -3
- mindspore/train/data_sink.py +4 -4
- mindspore/train/dataset_helper.py +5 -5
- mindspore/train/model.py +20 -4
- mindspore/train/serialization.py +15 -35
- mindspore/train/train_thor/model_thor.py +2 -2
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/hooks.py +81 -0
- mindspore/utils/utils.py +8 -8
- mindspore/version.py +1 -1
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +1 -1
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +193 -192
- mindspore/_extends/parallel_compile/akg_compiler/custom.py +0 -1109
- mindspore/common/dynamic_shape/__init__.py +0 -0
- mindspore/common/dynamic_shape/enable_dynamic.py +0 -197
- /mindspore/common/{dynamic_shape/_auto_dynamic.py → _auto_dynamic.py} +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.7.0.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
|
@@ -250,11 +250,11 @@ def add_ext(input, other, alpha=1):
|
|
|
250
250
|
input (Union[Tensor, number.Number, bool]): The first input is a number.Number or
|
|
251
251
|
a bool or a tensor whose data type is
|
|
252
252
|
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ or
|
|
253
|
-
`
|
|
253
|
+
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_.
|
|
254
254
|
other (Union[Tensor, number.Number, bool]): The second input, is a number.Number or
|
|
255
255
|
a bool or a tensor whose data type is
|
|
256
256
|
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ or
|
|
257
|
-
`
|
|
257
|
+
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_.
|
|
258
258
|
alpha (number.Number): A scaling factor applied to `other`, default 1.
|
|
259
259
|
|
|
260
260
|
Returns:
|
|
@@ -312,7 +312,7 @@ def add(input, other):
|
|
|
312
312
|
|
|
313
313
|
Note:
|
|
314
314
|
- The two inputs can not be bool type at the same time,
|
|
315
|
-
[True, Tensor(True), Tensor(np.array([True]))] are all considered bool type.
|
|
315
|
+
[True, Tensor(True, bool\_), Tensor(np.array([True]), bool\_)] are all considered bool type.
|
|
316
316
|
- Support broadcast, support implicit type conversion and type promotion.
|
|
317
317
|
- When the input is a tensor, the dimension should be greater than or equal to 1.
|
|
318
318
|
|
|
@@ -1985,112 +1985,6 @@ def count_nonzero(input, dim=None):
|
|
|
1985
1985
|
return count_nonzero_op(input, dim)
|
|
1986
1986
|
|
|
1987
1987
|
|
|
1988
|
-
def cross_entropy_loss_grad(grad_loss, log_prob, target, weight=None, grad_zloss=None, lse_for_zloss=None, reduction='mean', ignore_index=-100, label_smoothing=0.0, lse_square_scale_for_zloss=0.0):
|
|
1989
|
-
r"""
|
|
1990
|
-
|
|
1991
|
-
"""
|
|
1992
|
-
return cross_entropy_loss_grad_op(grad_loss, log_prob, target, weight, grad_zloss, lse_for_zloss, reduction, ignore_index, label_smoothing, lse_square_scale_for_zloss)
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
def cross_entropy_loss(input, target, weight=None, reduction='mean', ignore_index=-100, label_smoothing=0.0, lse_square_scale_for_zloss=0.0, return_zloss=False):
|
|
1996
|
-
r"""
|
|
1997
|
-
Computes the cross entropy loss between input and target.
|
|
1998
|
-
|
|
1999
|
-
Assume the number of classes :math:`C` in the range :math:`[0, C)`,
|
|
2000
|
-
the loss with reduction=none can be described as:
|
|
2001
|
-
|
|
2002
|
-
.. math::
|
|
2003
|
-
|
|
2004
|
-
\ell(x, y) = L = \{l_1,\dots,l_N\}^\top, \quad
|
|
2005
|
-
l_n = - w_{y_n} \log \frac{\exp(x_{n,y_n})}{\sum_{c=1}^C \exp(x_{n,c})}
|
|
2006
|
-
\cdot \mathbb{1}\{y_n \not= \text{ignore_index}\}
|
|
2007
|
-
|
|
2008
|
-
where :math:`x` is the inputs, :math:`y` is the target, :math:`w` is the weight, :math:`N` is the batch size,
|
|
2009
|
-
:math:`c` belonging to :math:`[0, C-1]` is class index, where :math:`C` is the number of classes.
|
|
2010
|
-
|
|
2011
|
-
If `reduction` is not ``None`` (default ``'mean'`` ), then
|
|
2012
|
-
|
|
2013
|
-
.. math::
|
|
2014
|
-
|
|
2015
|
-
\ell(x, y) = \begin{cases}
|
|
2016
|
-
\sum_{n=1}^N \frac{1}{\sum_{n=1}^N w_{y_n} \cdot \mathbb{1}\{y_n \not= \text{ignore_index}\}} l_n, &
|
|
2017
|
-
\text{if reduction} = \text{'mean',}\\
|
|
2018
|
-
\sum_{n=1}^N l_n, &
|
|
2019
|
-
\text{if reduction} = \text{'sum'.}
|
|
2020
|
-
\end{cases}
|
|
2021
|
-
|
|
2022
|
-
.. warning::
|
|
2023
|
-
This is an experimental API that is subject to change or deletion.
|
|
2024
|
-
|
|
2025
|
-
Inputs:
|
|
2026
|
-
- **input** (Tensor) - Tensor of shape of :math:`(N, C)` where `C = number of classes`, data type must be bfloat16, float16 or float32.
|
|
2027
|
-
- **target** (Tensor) - For class indices, tensor of shape :math:`(N)`, data type must be int64. The value must be in range [0, C).
|
|
2028
|
-
- **weight** (Tensor, optional) - A rescaling weight applied to the loss of each batch element.
|
|
2029
|
-
If not None, the shape is :math:`(C,)`, data type must be float32. Default: ``None`` .
|
|
2030
|
-
- **reduction** (str, optional) - Apply specific reduction method to the output: ``'none'`` , ``'mean'`` ,
|
|
2031
|
-
``'sum'`` . Default: ``'mean'`` .
|
|
2032
|
-
|
|
2033
|
-
- ``'none'``: no reduction will be applied.
|
|
2034
|
-
- ``'mean'``: compute and return the weighted mean of elements in the output.
|
|
2035
|
-
- ``'sum'``: the output elements will be summed.
|
|
2036
|
-
|
|
2037
|
-
- **ignore_index** (int, optional) - Specifies a target value that is ignored and does not contribute to the input
|
|
2038
|
-
gradient. When set to negative values, no target value is ignored. It should be int64.
|
|
2039
|
-
Default: ``-100`` .
|
|
2040
|
-
- **label_smoothing** (float, optional) - Label smoothing values, a regularization tool used to prevent the model
|
|
2041
|
-
from overfitting when calculating Loss. This value must be 0.0 currently. Default: ``0.0`` .
|
|
2042
|
-
- **lse_square_scale_for_zloss** (float, optional) - The value range is [0.0, 1.0), not enabled for now, can only be 0.0. Default: ``0.0`` .
|
|
2043
|
-
- **return_zloss** (float, optional) - Not enabled for now, can only be ``False``. Default: ``False`` .
|
|
2044
|
-
|
|
2045
|
-
Outputs:
|
|
2046
|
-
A tuple consisting of 4 Tensors.
|
|
2047
|
-
|
|
2048
|
-
- **loss** (Tensor) - loss between `input` and `target`, the dtype is the same as `input`.
|
|
2049
|
-
|
|
2050
|
-
- If `reduction` is ``'none'`` , the shape is :math:`(N,)` .
|
|
2051
|
-
- If `reduction` is ``'sum'` or ``'mean'`, the shape is :math:`(1,)` .
|
|
2052
|
-
|
|
2053
|
-
- **log_prob** (Tensor) - the shape is :math:`(N, C)` with the same dtype as `input`.
|
|
2054
|
-
- **zloss** (Tensor) - the shape is :math:`(N,)` if `return_zloss` is True, or the shape is :math:`(0,)` with the same dtype as `input`. This parameter is disabled for now.
|
|
2055
|
-
- **lse_for_zloss** (Tensor) - the shape is :math:`(N,)` if `lse_square_scale_for_zloss` is not 0.0, or the shape is :math:`(0,)` with the same dtype as `input`. This parameter is disabled for now.
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
Raises:
|
|
2059
|
-
ValueError: If `reduction` is not one of ``'none'``, ``'mean'`` or ``'sum'``.
|
|
2060
|
-
TypeError: If `input`, `target` or `weight` is not a Tensor.
|
|
2061
|
-
|
|
2062
|
-
Supported Platforms:
|
|
2063
|
-
``Ascend``
|
|
2064
|
-
|
|
2065
|
-
Examples:
|
|
2066
|
-
>>> import mindspore
|
|
2067
|
-
>>> import numpy as np
|
|
2068
|
-
>>> from mindspore import Tensor, nn, ops
|
|
2069
|
-
>>>
|
|
2070
|
-
>>>
|
|
2071
|
-
>>> class Net(nn.Cell):
|
|
2072
|
-
... def __init__(self):
|
|
2073
|
-
... super(Net, self).__init__()
|
|
2074
|
-
... self.cross_entropy_loss = ops.auto_generate.CrossEntropyLoss()
|
|
2075
|
-
...
|
|
2076
|
-
... def construct(self, input, target, weight):
|
|
2077
|
-
... result = self.cross_entropy_loss(input, target, weight)
|
|
2078
|
-
... return result
|
|
2079
|
-
...
|
|
2080
|
-
>>>
|
|
2081
|
-
>>> net = Net()
|
|
2082
|
-
>>> input = Tensor(np.array([[0.2, 0.7, 0.1], [0.2, 0.7, 0.1]]), mindspore.float32)
|
|
2083
|
-
>>> target = Tensor(np.array([0, 1]), mindspore.int64)
|
|
2084
|
-
>>> weight = Tensor(np.array([1, 0.5, 0.5]), mindspore.float32)
|
|
2085
|
-
>>> output = net(input, target, weight)
|
|
2086
|
-
>>> print(output[:2])
|
|
2087
|
-
(Tensor(shape=[1], dtype=Float32, value= [ 1.10128295e+00]), Tensor(shape=[2, 3], dtype=Float32, value=
|
|
2088
|
-
[[-1.26794958e+00, -7.67949641e-01, -1.36794960e+00],
|
|
2089
|
-
[-1.26794958e+00, -7.67949641e-01, -1.36794960e+00]]))
|
|
2090
|
-
"""
|
|
2091
|
-
return cross_entropy_loss_op(input, target, weight, reduction, ignore_index, label_smoothing, lse_square_scale_for_zloss, return_zloss)
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
1988
|
def cummax(input, axis):
|
|
2095
1989
|
r"""
|
|
2096
1990
|
Return the cumulative maximum values and their indices along the given axis of the tensor.
|
|
@@ -3632,7 +3526,7 @@ def gather(input_params, input_indices, axis, batch_dims=0):
|
|
|
3632
3526
|
- The value of input_indices must be in the range of `[0, input_param.shape[axis])`.
|
|
3633
3527
|
On CPU and GPU, an error is raised if an out of bound indice is found. On Ascend, the results may be
|
|
3634
3528
|
undefined.
|
|
3635
|
-
- The data type of input_params cannot be `mindspore.
|
|
3529
|
+
- The data type of input_params cannot be `mindspore.bool_` .
|
|
3636
3530
|
- The shape of returned tensor is :math:`input\_params.shape[:axis] + input\_indices.shape[batch\_dims:] + input\_params.shape[axis + 1:]` .
|
|
3637
3531
|
|
|
3638
3532
|
Args:
|
|
@@ -4728,7 +4622,7 @@ def index(input, indices):
|
|
|
4728
4622
|
[2 6 5]
|
|
4729
4623
|
>>> input2 = Tensor(np.arange(4 * 3 * 3).reshape(4, 3, 3), mindspore.int32)
|
|
4730
4624
|
>>> indices3 = Tensor(np.array([1, 0]), mindspore.int32)
|
|
4731
|
-
>>> indices4 = Tensor(np.array([1, 1, 0]), mindspore.
|
|
4625
|
+
>>> indices4 = Tensor(np.array([1, 1, 0]), mindspore.bool_)
|
|
4732
4626
|
>>> output2 = ops.auto_generate.index(input2, [indices3, indices4])
|
|
4733
4627
|
>>> print(output2)
|
|
4734
4628
|
[[ 9 10 11]
|
|
@@ -4804,20 +4698,6 @@ def inplace_add_ext(input, other, alpha=1):
|
|
|
4804
4698
|
return inplace_add_ext_op(input, other, alpha)
|
|
4805
4699
|
|
|
4806
4700
|
|
|
4807
|
-
def inplace_bernoulli_scalar(input, p, seed, offset):
|
|
4808
|
-
r"""
|
|
4809
|
-
|
|
4810
|
-
"""
|
|
4811
|
-
return inplace_bernoulli_scalar_op(input, p, seed, offset)
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
def inplace_bernoulli_tensor(input, p, seed, offset):
|
|
4815
|
-
r"""
|
|
4816
|
-
|
|
4817
|
-
"""
|
|
4818
|
-
return inplace_bernoulli_tensor_op(input, p, seed, offset)
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
4701
|
def inplace_clamp_scalar(input, min=None, max=None):
|
|
4822
4702
|
r"""
|
|
4823
4703
|
|
|
@@ -4832,11 +4712,11 @@ def inplace_clamp_tensor(input, min=None, max=None):
|
|
|
4832
4712
|
return inplace_clamp_tensor_op(input, min, max)
|
|
4833
4713
|
|
|
4834
4714
|
|
|
4835
|
-
def inplace_copy(input, src
|
|
4715
|
+
def inplace_copy(input, src):
|
|
4836
4716
|
r"""
|
|
4837
4717
|
|
|
4838
4718
|
"""
|
|
4839
|
-
return inplace_copy_op(input, src
|
|
4719
|
+
return inplace_copy_op(input, src)
|
|
4840
4720
|
|
|
4841
4721
|
|
|
4842
4722
|
def divmod_scalar_(input, other, rounding_mode=None):
|
|
@@ -5611,13 +5491,6 @@ def kthvalue(input, k, dim=-1, keepdim=False):
|
|
|
5611
5491
|
return kthvalue_op(input, k, dim, keepdim)
|
|
5612
5492
|
|
|
5613
5493
|
|
|
5614
|
-
def kv_scale_cache(key_scale, value_scale, key_value_scale_cache, batch_valid_length, cache_mode):
|
|
5615
|
-
r"""
|
|
5616
|
-
|
|
5617
|
-
"""
|
|
5618
|
-
return kv_scale_cache_op(key_scale, value_scale, key_value_scale_cache, batch_valid_length, cache_mode)
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
5494
|
def l1_loss_ext(input, target, reduction='mean'):
|
|
5622
5495
|
r"""
|
|
5623
5496
|
Calculate the mean absolute error between the `input` value and the `target` value.
|
|
@@ -6273,7 +6146,7 @@ def masked_fill(input_x, mask, value):
|
|
|
6273
6146
|
Examples:
|
|
6274
6147
|
>>> import mindspore
|
|
6275
6148
|
>>> input_x = mindspore.tensor([1., 2., 3., 4.], mindspore.float32)
|
|
6276
|
-
>>> mask = mindspore.tensor([True, True, False, True], mindspore.
|
|
6149
|
+
>>> mask = mindspore.tensor([True, True, False, True], mindspore.bool_)
|
|
6277
6150
|
>>> output = mindspore.ops.masked_fill(input_x, mask, 0.5)
|
|
6278
6151
|
>>> print(output)
|
|
6279
6152
|
[0.5 0.5 3. 0.5]
|
|
@@ -6281,13 +6154,6 @@ def masked_fill(input_x, mask, value):
|
|
|
6281
6154
|
return masked_fill_op(input_x, mask, value)
|
|
6282
6155
|
|
|
6283
6156
|
|
|
6284
|
-
def masked_scatter(input, mask, source):
|
|
6285
|
-
r"""
|
|
6286
|
-
|
|
6287
|
-
"""
|
|
6288
|
-
return masked_scatter_op(input, mask, source)
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
6157
|
def masked_select(input, mask):
|
|
6292
6158
|
r"""
|
|
6293
6159
|
Return a new 1-D tensor which indexes the `input` tensor according to the boolean `mask`.
|
|
@@ -6307,7 +6173,7 @@ def masked_select(input, mask):
|
|
|
6307
6173
|
Examples:
|
|
6308
6174
|
>>> import mindspore
|
|
6309
6175
|
>>> x = mindspore.tensor([1, 2, 3, 4], mindspore.int64)
|
|
6310
|
-
>>> mask = mindspore.tensor([1, 0, 1, 0], mindspore.
|
|
6176
|
+
>>> mask = mindspore.tensor([1, 0, 1, 0], mindspore.bool_)
|
|
6311
6177
|
>>> output = mindspore.ops.masked_select(x, mask)
|
|
6312
6178
|
>>> print(output)
|
|
6313
6179
|
[1 3]
|
|
@@ -6684,20 +6550,6 @@ def mish_ext(input):
|
|
|
6684
6550
|
return mish_ext_op(input)
|
|
6685
6551
|
|
|
6686
6552
|
|
|
6687
|
-
def mla(query, q_rope, kv_cache, k_rope, block_tables, attn_mask=None, deq_scale_qk=None, deq_scale_pv=None, q_seq_lens=None, context_lens=None, head_num=32, scale_value=0.0, kv_head_num=1, mask_mode='MASK_NONE', is_ring=0):
|
|
6688
|
-
r"""
|
|
6689
|
-
|
|
6690
|
-
"""
|
|
6691
|
-
return mla_op(query, q_rope, kv_cache, k_rope, block_tables, attn_mask, deq_scale_qk, deq_scale_pv, q_seq_lens, context_lens, head_num, scale_value, kv_head_num, mask_mode, is_ring)
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
def mla_preprocess(input1, gamma1, beta1, quant_scale1, quant_offset1, wdqkv, bias1, gamma2, beta2, quant_scale2, quant_offset2, gamma3, sin1, cos1, sin2, cos2, key_cache, slot_mapping, wuq, bias2, slot_wuk, de_scale1, de_scale2, ctkv_scale, qnope_scale, krope_cache, param_cache_mode=0):
|
|
6695
|
-
r"""
|
|
6696
|
-
|
|
6697
|
-
"""
|
|
6698
|
-
return mla_preprocess_op(input1, gamma1, beta1, quant_scale1, quant_offset1, wdqkv, bias1, gamma2, beta2, quant_scale2, quant_offset2, gamma3, sin1, cos1, sin2, cos2, key_cache, slot_mapping, wuq, bias2, slot_wuk, de_scale1, de_scale2, ctkv_scale, qnope_scale, krope_cache, param_cache_mode)
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
6553
|
def mm_ext(input, mat2):
|
|
6702
6554
|
r"""
|
|
6703
6555
|
Returns the matrix product of two arrays.
|
|
@@ -7126,7 +6978,7 @@ def mul(input, other):
|
|
|
7126
6978
|
- When the two inputs have different shapes,
|
|
7127
6979
|
they must be able to broadcast to a common shape.
|
|
7128
6980
|
- The two inputs can not be bool type at the same time,
|
|
7129
|
-
[True, Tensor(True), Tensor(np.array([True]))] are all considered bool type.
|
|
6981
|
+
[True, Tensor(True, bool\_), Tensor(np.array([True]), bool\_)] are all considered bool type.
|
|
7130
6982
|
- Support implicit type conversion and type promotion.
|
|
7131
6983
|
|
|
7132
6984
|
Args:
|
|
@@ -7522,10 +7374,8 @@ def prelu(input, weight):
|
|
|
7522
7374
|
:align: center
|
|
7523
7375
|
|
|
7524
7376
|
.. note::
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
- In GE mode, the rank of the input tensor must be greater than 1;
|
|
7528
|
-
otherwise, an error will be triggered.
|
|
7377
|
+
Channel dim is the 2nd dim of input. When input has dims < 2, then there is
|
|
7378
|
+
no channel dim and the number of channels = 1.
|
|
7529
7379
|
|
|
7530
7380
|
Args:
|
|
7531
7381
|
input (Tensor): The input Tensor of the activation function.
|
|
@@ -8170,78 +8020,6 @@ def rfft(input, n=None, dim=-1, norm=None):
|
|
|
8170
8020
|
return rfft_op(input, n, dim, norm)
|
|
8171
8021
|
|
|
8172
8022
|
|
|
8173
|
-
def ring_attention_update(prev_attn_out, prev_softmax_max, prev_softmax_sum, cur_attn_out, cur_softmax_max, cur_softmax_sum, actual_seq_qlen=None, layout='SBH'):
|
|
8174
|
-
r"""
|
|
8175
|
-
The RingAttentionUpdate operator updates the output of two FlashAttention operations based on their respective softmax max and softmax sum values.
|
|
8176
|
-
|
|
8177
|
-
- S: Sequence length
|
|
8178
|
-
- B: Batch dimension
|
|
8179
|
-
- H: Hidden layer size, equals to N * D
|
|
8180
|
-
- T: time, equals to B*S
|
|
8181
|
-
- N: Number of attention heads
|
|
8182
|
-
- D: Head dimension
|
|
8183
|
-
|
|
8184
|
-
.. warning::
|
|
8185
|
-
- It is only supported on Atlas A2 Training Series Products.
|
|
8186
|
-
- This is an experimental API that is subject to change or deletion.
|
|
8187
|
-
- When `layout` is ``"TND"``, the last dimension of `prev_attn_out` must be a multiple of 64.
|
|
8188
|
-
- When `layout` is ``"TND"``, `actual_seq_qlen` is mandatory.
|
|
8189
|
-
- When `layout` is ``"TND"``, N x D must satisfy the constraint:
|
|
8190
|
-
(AlignUp(NxD, 64)x(DataSizex6+8))+(AlignUp(Nx8, 64)x56) <= 192x1024.
|
|
8191
|
-
DataSize is 4 bytes when `prev_attn_out` dtype is float32, 2 bytes when dtype is float16 / bfloat16.
|
|
8192
|
-
- When `layout` is ``"TND"``, if `actual_seq_qlen` is not a non-decreasing sequence from 0 to T, the result is undefined.
|
|
8193
|
-
|
|
8194
|
-
Args:
|
|
8195
|
-
prev_attn_out (Tensor): Output of the first FlashAttention operation. The dtype is float16, float32, bfloat16.
|
|
8196
|
-
The shape is :math:`(S, B, H)` or :math:`(T, N, D)`.
|
|
8197
|
-
prev_softmax_max (Tensor): The max values from the first FlashAttention softmax computation. The dtype float32.
|
|
8198
|
-
The shape is :math:`(B, N, S, 8)` or :math:`(T, N, 8)`. The last dimension contains 8 identical values, which must be positive.
|
|
8199
|
-
prev_softmax_sum (Tensor): The sum values from the first FlashAttention softmax computation.
|
|
8200
|
-
It has the same shape and dtype as `prev_softmax_max`.
|
|
8201
|
-
cur_attn_out (Tensor): Output of the second FlashAttention operation. It has the same shape and dtype as `prev_attn_out`.
|
|
8202
|
-
cur_softmax_max (Tensor): The max values from the second FlashAttention softmax computation. It has the same shape and dtype as `prev_softmax_max`.
|
|
8203
|
-
cur_softmax_sum (Tensor):The sum values from the second FlashAttention softmax computation. It has the same shape and dtype as `prev_softmax_max`.
|
|
8204
|
-
actual_seq_qlen (Tensor, optional): Cumulative sequence length, starting from 0. Required if `layout` is ``"TND"``. Does not take effect if `layout` is ``"SBH"``.
|
|
8205
|
-
The tensor must be 1D and contain non-decreasing integer values starting from 0 to T. Default: ``None``.
|
|
8206
|
-
layout (str, optional): Indicates the input layout, currently support ``"TND"`` and ``"SBH"``. Default: ``"SBH"``.
|
|
8207
|
-
|
|
8208
|
-
Returns:
|
|
8209
|
-
tuple (Tensor), tuple of 3 tensors.
|
|
8210
|
-
|
|
8211
|
-
- **attn_out** (Tensor) - The updated attention out, with the same shape and dtype as `prev_attn_out`.
|
|
8212
|
-
- **softmax_max** (Tensor) - The updated softmax max values, with the same shape and dtype as `prev_softmax_max`.
|
|
8213
|
-
- **softmax_sum** (Tensor) - The updated softmax sum values, with the same shape and dtype as `prev_softmax_max`.
|
|
8214
|
-
|
|
8215
|
-
Raises:
|
|
8216
|
-
RuntimeError: If `layout` is ``"TND"``, and `prev_attn_out`'s last dimension is not aligned to 64.
|
|
8217
|
-
RuntimeError: If `layout` is ``"TND"``, and `actual_seq_qlen` is not provided.
|
|
8218
|
-
RuntimeError: If `layout` is ``"TND"``, and `actual_seq_qlen` is not a non-decreasing sequence from 0 to T.
|
|
8219
|
-
RuntimeError: If `layout` is ``"TND"``, and `prev_attn_out` exceeds the size constraints.
|
|
8220
|
-
|
|
8221
|
-
Supported Platforms:
|
|
8222
|
-
``Ascend``
|
|
8223
|
-
|
|
8224
|
-
Examples:
|
|
8225
|
-
>>> import numpy as np
|
|
8226
|
-
>>> import mindspore
|
|
8227
|
-
>>> from mindspore import Tensor, ops
|
|
8228
|
-
>>> np.random.seed(123)
|
|
8229
|
-
>>> S, B, H, N= 4, 6, 16, 8
|
|
8230
|
-
>>> prev_attn_out = np.random.uniform(-1.0, 1.0, size=(S, B, H)).astype(np.float32)
|
|
8231
|
-
>>> prev_softmax_max = np.random.uniform(-1.0, 1.0, size=(B, N, S, 8)).astype(np.float32)
|
|
8232
|
-
>>> prev_softmax_sum = np.random.uniform(-1.0, 1.0, size=(B, N, S, 8)).astype(np.float32)
|
|
8233
|
-
>>> cur_attn_out = np.random.uniform(-1.0, 1.0, size=(S, B, H)).astype(np.float32)
|
|
8234
|
-
>>> cur_softmax_max = np.random.uniform(-1.0, 1.0, size=(B, N, S, 8)).astype(np.float32)
|
|
8235
|
-
>>> cur_softmax_sum = np.random.uniform(-1.0, 1.0, size=(B, N, S, 8)).astype(np.float32)
|
|
8236
|
-
>>> inputs_np = [prev_attn_out, prev_softmax_max, prev_softmax_sum, cur_attn_out, cur_softmax_max, cur_softmax_sum]
|
|
8237
|
-
>>> inputs_ms = [Tensor(item) for item in inputs_np]
|
|
8238
|
-
>>> out = ops.ring_attention_update(*inputs_ms)
|
|
8239
|
-
>>> print(out[0].shape)
|
|
8240
|
-
(4, 6, 16)
|
|
8241
|
-
"""
|
|
8242
|
-
return ring_attention_update_op(prev_attn_out, prev_softmax_max, prev_softmax_sum, cur_attn_out, cur_softmax_max, cur_softmax_sum, actual_seq_qlen, layout)
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
8023
|
def rms_norm(x, gamma, epsilon=1e-6):
|
|
8246
8024
|
r"""
|
|
8247
8025
|
The RmsNorm(Root Mean Square Layer Normalization) operator is a normalization operation. Compared to
|
|
@@ -8437,7 +8215,7 @@ def scalar_cast(input_x, input_y):
|
|
|
8437
8215
|
|
|
8438
8216
|
Args:
|
|
8439
8217
|
input_x (scalar): The input scalar. Only constant value is allowed.
|
|
8440
|
-
input_y (mindspore.dtype): The type to be cast. Only constant value is allowed. And the value should only be mindspore.int64, mindspore.float64, or mindspore.
|
|
8218
|
+
input_y (mindspore.dtype): The type to be cast. Only constant value is allowed. And the value should only be mindspore.int64, mindspore.float64, or mindspore.bool_.
|
|
8441
8219
|
|
|
8442
8220
|
Returns:
|
|
8443
8221
|
Scalar. The type is the same as the python type corresponding to `input_y`.
|
|
@@ -8947,58 +8725,6 @@ def sin(input):
|
|
|
8947
8725
|
return sin_op(input)
|
|
8948
8726
|
|
|
8949
8727
|
|
|
8950
|
-
def smooth_l1_loss(prediction, target, beta=1.0, reduction='none'):
|
|
8951
|
-
r"""
|
|
8952
|
-
Calculate the smooth L1 loss, and the L1 loss function has robustness.
|
|
8953
|
-
|
|
8954
|
-
Refer to :func:`mindspore.ops.smooth_l1_loss` for more details.
|
|
8955
|
-
|
|
8956
|
-
.. warning::
|
|
8957
|
-
This API has poor performance on CPU and it is recommended to run it on the Ascend/GPU.
|
|
8958
|
-
|
|
8959
|
-
Args:
|
|
8960
|
-
beta (number, optional): A parameter used to control the point where the function will change between
|
|
8961
|
-
L1 to L2 loss. Default: ``1.0`` .
|
|
8962
|
-
|
|
8963
|
-
- Ascend: The value should be equal to or greater than zero.
|
|
8964
|
-
- CPU/GPU: The value should be greater than zero.
|
|
8965
|
-
reduction (str, optional): Apply specific reduction method to the output: ``'none'`` , ``'mean'`` ,
|
|
8966
|
-
``'sum'`` . Default: ``'none'`` .
|
|
8967
|
-
|
|
8968
|
-
- ``'none'``: no reduction will be applied.
|
|
8969
|
-
- ``'mean'``: compute and return the mean of elements in the output.
|
|
8970
|
-
- ``'sum'``: the output elements will be summed.
|
|
8971
|
-
|
|
8972
|
-
Inputs:
|
|
8973
|
-
- **logits** (Tensor) - Input Tensor of any dimension. Supported dtypes:
|
|
8974
|
-
|
|
8975
|
-
- Ascend: float16, float32, bfloat16.
|
|
8976
|
-
- CPU/GPU: float16, float32, float64.
|
|
8977
|
-
- **labels** (Tensor) - Ground truth data.
|
|
8978
|
-
|
|
8979
|
-
- CPU/Ascend: has the same shape as the `logits`, `logits` and `labels` comply with the implicit type conversion rules to make the data types consistent.
|
|
8980
|
-
- GPU: has the same shape and dtype as the `logits`.
|
|
8981
|
-
|
|
8982
|
-
Outputs:
|
|
8983
|
-
Tensor, if `reduction` is ``'none'``, then output is a tensor with the same shape as `logits`. Otherwise the shape of output tensor is :math:`()`.
|
|
8984
|
-
|
|
8985
|
-
Supported Platforms:
|
|
8986
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
8987
|
-
|
|
8988
|
-
Examples:
|
|
8989
|
-
>>> import mindspore
|
|
8990
|
-
>>> import numpy as np
|
|
8991
|
-
>>> from mindspore import Tensor, ops
|
|
8992
|
-
>>> loss = ops.SmoothL1Loss()
|
|
8993
|
-
>>> logits = Tensor(np.array([1, 2, 3]), mindspore.float32)
|
|
8994
|
-
>>> labels = Tensor(np.array([1, 2, 2]), mindspore.float32)
|
|
8995
|
-
>>> output = loss(logits, labels)
|
|
8996
|
-
>>> print(output)
|
|
8997
|
-
[0. 0. 0.5]
|
|
8998
|
-
"""
|
|
8999
|
-
return smooth_l1_loss_impl(prediction, target, beta, reduction)
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
8728
|
def softplus_ext(input, beta=1, threshold=20):
|
|
9003
8729
|
r"""
|
|
9004
8730
|
Applies softplus function to `input` element-wise.
|
|
@@ -9458,11 +9184,11 @@ def sub_ext(input, other, alpha=1):
|
|
|
9458
9184
|
input (Union[Tensor, number.Number, bool]): The first input is a number.Number or
|
|
9459
9185
|
a bool or a tensor whose data type is
|
|
9460
9186
|
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ or
|
|
9461
|
-
`
|
|
9187
|
+
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_.
|
|
9462
9188
|
other (Union[Tensor, number.Number, bool]): The second input, is a number.Number or
|
|
9463
9189
|
a bool or a tensor whose data type is
|
|
9464
9190
|
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_ or
|
|
9465
|
-
`
|
|
9191
|
+
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_.
|
|
9466
9192
|
alpha (number.Number): A scaling factor applied to `other`, default 1.
|
|
9467
9193
|
|
|
9468
9194
|
Returns:
|
|
@@ -9507,7 +9233,7 @@ def sub(input, other):
|
|
|
9507
9233
|
Note:
|
|
9508
9234
|
- When the two inputs have different shapes, they must be able to broadcast to a common shape.
|
|
9509
9235
|
- The two inputs can not be bool type at the same time,
|
|
9510
|
-
[True, Tensor(True), Tensor(np.array([True]))] are all considered bool type.
|
|
9236
|
+
[True, Tensor(True, bool\_), Tensor(np.array([True]), bool\_)] are all considered bool type.
|
|
9511
9237
|
- Support implicit type conversion and type promotion.
|
|
9512
9238
|
|
|
9513
9239
|
Args:
|