mindspore 2.3.0rc1__cp37-cp37m-manylinux1_x86_64.whl → 2.3.0rc2__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.
- mindspore/.commit_id +1 -1
- mindspore/__init__.py +1 -1
- mindspore/_akg/akg/utils/tbe_codegen_utils.py +13 -3
- mindspore/_c_dataengine.cpython-37m-x86_64-linux-gnu.so +0 -0
- mindspore/_c_expression.cpython-37m-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-37m-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
|
@@ -35,12 +35,14 @@ from mindspore.common import Tensor, CSRTensor, COOTensor
|
|
|
35
35
|
from mindspore._c_expression import Tensor as Tensor_
|
|
36
36
|
from mindspore._c_expression import CSRTensor as CSRTensor_
|
|
37
37
|
from mindspore._c_expression import COOTensor as COOTensor_
|
|
38
|
-
from ..auto_generate import (ExpandDims, Reshape, TensorShape, Transpose, Gather,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
from ..auto_generate import (ExpandDims, Reshape, TensorShape, Transpose, Gather,
|
|
39
|
+
OnesLike, ZerosLike, Argmax, ArgMaxExt,
|
|
40
|
+
ReverseV2, Diag, Eye, ScatterNd, ResizeNearestNeighborV2,
|
|
41
|
+
GatherNd, GatherD, Range, MaskedFill, RightShift, NonZero,
|
|
42
|
+
ResizeNearestNeighbor, Identity, Split, CumSum, CumProd,
|
|
43
|
+
Cummax, Cummin, Argmin, Concat, UnsortedSegmentSum, ScalarToTensor,
|
|
44
|
+
Tril, Triu, BroadcastTo, StridedSlice, Select, TopkExt)
|
|
45
|
+
from .manually_defined import Rank, Shape, Tile, Cast, Ones, Zeros
|
|
44
46
|
from ..auto_generate import ArgMaxWithValue, ArgMinWithValue
|
|
45
47
|
|
|
46
48
|
class _ScatterOp(PrimitiveWithInfer):
|
|
@@ -817,7 +819,7 @@ class Size(Primitive):
|
|
|
817
819
|
|
|
818
820
|
Inputs:
|
|
819
821
|
- **input_x** (Tensor) - Input parameters, the shape of tensor is :math:`(x_1, x_2, ..., x_R)`. The data type is
|
|
820
|
-
`number <https://www.mindspore.cn/docs/en/
|
|
822
|
+
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
|
821
823
|
|
|
822
824
|
Outputs:
|
|
823
825
|
int. A scalar representing the elements' size of `input_x`, tensor is the number of elements
|
|
@@ -1289,81 +1291,6 @@ class FillV2(PrimitiveWithCheck):
|
|
|
1289
1291
|
return Tensor(np.full(dims, x.asnumpy()))
|
|
1290
1292
|
|
|
1291
1293
|
|
|
1292
|
-
class Ones(Primitive):
|
|
1293
|
-
r"""
|
|
1294
|
-
Creates a tensor filled with value ones.
|
|
1295
|
-
|
|
1296
|
-
Refer to :func:`mindspore.ops.ones` for more details.
|
|
1297
|
-
|
|
1298
|
-
Inputs:
|
|
1299
|
-
- **shape** (Union[tuple[int], int]) - The specified shape of output tensor.
|
|
1300
|
-
- **type** (:class:`mindspore.dtype`) - The specified type of output tensor.
|
|
1301
|
-
|
|
1302
|
-
Outputs:
|
|
1303
|
-
Tensor, has the same type and shape as input shape value.
|
|
1304
|
-
|
|
1305
|
-
Supported Platforms:
|
|
1306
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
1307
|
-
|
|
1308
|
-
Examples:
|
|
1309
|
-
>>> import mindspore
|
|
1310
|
-
>>> from mindspore import ops
|
|
1311
|
-
>>> ones = ops.Ones()
|
|
1312
|
-
>>> output = ones((2, 2), mindspore.float32)
|
|
1313
|
-
>>> print(output)
|
|
1314
|
-
[[1. 1.]
|
|
1315
|
-
[1. 1.]]
|
|
1316
|
-
>>> output = ones((3, 3), mindspore.float32)
|
|
1317
|
-
>>> print(output)
|
|
1318
|
-
[[1. 1. 1.]
|
|
1319
|
-
[1. 1. 1.]
|
|
1320
|
-
[1. 1. 1.]]
|
|
1321
|
-
"""
|
|
1322
|
-
|
|
1323
|
-
@prim_attr_register
|
|
1324
|
-
def __init__(self):
|
|
1325
|
-
"""Initialize Ones"""
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
class Zeros(Primitive):
|
|
1329
|
-
r"""
|
|
1330
|
-
Zeros will be deprecated in the future. Please use class `mindspore.ops.zeros` instead.
|
|
1331
|
-
|
|
1332
|
-
Creates a tensor filled with value zeros.
|
|
1333
|
-
|
|
1334
|
-
Creates a tensor with shape described by the first argument and
|
|
1335
|
-
fills it with value zeros in type of the second argument.
|
|
1336
|
-
|
|
1337
|
-
Inputs:
|
|
1338
|
-
- **shape** (Union[tuple[int], int]) - The specified shape of output tensor.
|
|
1339
|
-
- **type** (mindspore.dtype) - The specified type of output tensor.
|
|
1340
|
-
|
|
1341
|
-
Outputs:
|
|
1342
|
-
Tensor, has the same type and shape as input shape value.
|
|
1343
|
-
|
|
1344
|
-
Raises:
|
|
1345
|
-
TypeError: If `shape` is neither int nor tuple.
|
|
1346
|
-
TypeError: If `shape` is a tuple whose elements are not all int.
|
|
1347
|
-
|
|
1348
|
-
Supported Platforms:
|
|
1349
|
-
Deprecated
|
|
1350
|
-
|
|
1351
|
-
Examples:
|
|
1352
|
-
>>> import mindspore
|
|
1353
|
-
>>> from mindspore import ops
|
|
1354
|
-
>>> zeros = ops.Zeros()
|
|
1355
|
-
>>> output = zeros((2, 2), mindspore.float32)
|
|
1356
|
-
>>> print(output)
|
|
1357
|
-
[[0. 0.]
|
|
1358
|
-
[0. 0.]]
|
|
1359
|
-
|
|
1360
|
-
"""
|
|
1361
|
-
|
|
1362
|
-
@prim_attr_register
|
|
1363
|
-
def __init__(self):
|
|
1364
|
-
"""Initialize Zeros"""
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
1294
|
class TupleToArray(PrimitiveWithInfer):
|
|
1368
1295
|
"""
|
|
1369
1296
|
Converts a tuple to a tensor.
|
|
@@ -2836,80 +2763,6 @@ class ScatterSub(Primitive):
|
|
|
2836
2763
|
self.add_prim_attr('side_effect_mem', True)
|
|
2837
2764
|
|
|
2838
2765
|
|
|
2839
|
-
class Triu(Primitive):
|
|
2840
|
-
"""
|
|
2841
|
-
Returns the upper triangular portion of the 2-D matrix or the set of matrices
|
|
2842
|
-
in a batch. The remaining elements of the resulting Tensor are assigned a value of 0.
|
|
2843
|
-
The upper triangular section of the matrix comprises of the
|
|
2844
|
-
elements present on and above the main diagonal.
|
|
2845
|
-
|
|
2846
|
-
.. warning::
|
|
2847
|
-
This is an experimental API that is subject to change or deletion.
|
|
2848
|
-
|
|
2849
|
-
Args:
|
|
2850
|
-
diagonal (int, optional): The index of diagonal. Default: ``0`` , indicating the main diagonal.
|
|
2851
|
-
|
|
2852
|
-
Inputs:
|
|
2853
|
-
- **x** (Tensor) - The input tensor with shape :math:`(M, N, *)`
|
|
2854
|
-
where :math:`*` means any number of additional dimensions.
|
|
2855
|
-
|
|
2856
|
-
Outputs:
|
|
2857
|
-
- **y** (Tensor) - A tensor has the same shape and data type as input.
|
|
2858
|
-
|
|
2859
|
-
Raises:
|
|
2860
|
-
TypeError: If `x` is not a Tensor.
|
|
2861
|
-
TypeError: If `diagonal` is not an int.
|
|
2862
|
-
ValueError: If the dimension of `input` is less than 2.
|
|
2863
|
-
|
|
2864
|
-
Supported Platforms:
|
|
2865
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
2866
|
-
|
|
2867
|
-
Examples:
|
|
2868
|
-
>>> import numpy as np
|
|
2869
|
-
>>> from mindspore import Tensor, ops
|
|
2870
|
-
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
|
2871
|
-
... [ 5, 6, 7, 8],
|
|
2872
|
-
... [10, 11, 12, 13],
|
|
2873
|
-
... [14, 15, 16, 17]]))
|
|
2874
|
-
>>> triu = ops.Triu()
|
|
2875
|
-
>>> result = triu(x)
|
|
2876
|
-
>>> print(result)
|
|
2877
|
-
[[ 1 2 3 4]
|
|
2878
|
-
[ 0 6 7 8]
|
|
2879
|
-
[ 0 0 12 13]
|
|
2880
|
-
[ 0 0 0 17]]
|
|
2881
|
-
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
|
2882
|
-
... [ 5, 6, 7, 8],
|
|
2883
|
-
... [10, 11, 12, 13],
|
|
2884
|
-
... [14, 15, 16, 17]]))
|
|
2885
|
-
>>> triu = ops.Triu(diagonal=1)
|
|
2886
|
-
>>> result = triu(x)
|
|
2887
|
-
>>> print(result)
|
|
2888
|
-
[[ 0 2 3 4]
|
|
2889
|
-
[ 0 0 7 8]
|
|
2890
|
-
[ 0 0 0 13]
|
|
2891
|
-
[ 0 0 0 0]]
|
|
2892
|
-
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
|
2893
|
-
... [ 5, 6, 7, 8],
|
|
2894
|
-
... [10, 11, 12, 13],
|
|
2895
|
-
... [14, 15, 16, 17]]))
|
|
2896
|
-
>>> triu = ops.Triu(diagonal=-1)
|
|
2897
|
-
>>> result = triu(x)
|
|
2898
|
-
>>> print(result)
|
|
2899
|
-
[[ 1 2 3 4]
|
|
2900
|
-
[ 5 6 7 8]
|
|
2901
|
-
[ 0 11 12 13]
|
|
2902
|
-
[ 0 0 16 17]]
|
|
2903
|
-
"""
|
|
2904
|
-
|
|
2905
|
-
@prim_attr_register
|
|
2906
|
-
def __init__(self, diagonal=0):
|
|
2907
|
-
"""Initialize Triu"""
|
|
2908
|
-
validator.check_value_type("diagonal", diagonal, [int], self.name)
|
|
2909
|
-
self.diagonal = diagonal
|
|
2910
|
-
self.init_prim_io_names(inputs=['x'], outputs=['y'])
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
2766
|
class ScatterMul(_ScatterOpDynamic):
|
|
2914
2767
|
r"""
|
|
2915
2768
|
Updates the value of the input tensor through the multiply operation.
|
|
@@ -5190,8 +5043,6 @@ class TensorScatterElements(Primitive):
|
|
|
5190
5043
|
- **indices** (Tensor) - The index of `input_x` to do scatter operation whose data type must be int32 or
|
|
5191
5044
|
int64. It has the same rank as `data`. And accepted range is [-s, s) where s is the size along axis.
|
|
5192
5045
|
- **updates** (Tensor) - The tensor doing the scatter operation with `data`,
|
|
5193
|
-
it has the same shape and type as `data`.
|
|
5194
|
-
- **update** (Tensor) - The tensor doing the scatter operation with `data`,
|
|
5195
5046
|
it has the same type as `data` and the same shape as `indices`.
|
|
5196
5047
|
|
|
5197
5048
|
Outputs:
|
|
@@ -5560,80 +5411,6 @@ class LogSpace(Primitive):
|
|
|
5560
5411
|
self.init_prim_io_names(inputs=['start', 'end'], outputs=['y'])
|
|
5561
5412
|
|
|
5562
5413
|
|
|
5563
|
-
class Tril(Primitive):
|
|
5564
|
-
"""
|
|
5565
|
-
Returns the lower triangular portion of the 2-D matrix or the set of matrices
|
|
5566
|
-
in a batch. The remaining elements of the resulting Tensor are assigned a value of 0.
|
|
5567
|
-
The lower triangular section of the matrix comprises of the
|
|
5568
|
-
elements present on and below the main diagonal.
|
|
5569
|
-
|
|
5570
|
-
.. warning::
|
|
5571
|
-
This is an experimental API that is subject to change or deletion.
|
|
5572
|
-
|
|
5573
|
-
Args:
|
|
5574
|
-
diagonal (int, optional): An optional attribute indicates the diagonal to consider, default: ``0`` ,
|
|
5575
|
-
indicating the main diagonal.
|
|
5576
|
-
|
|
5577
|
-
Inputs:
|
|
5578
|
-
- **x** (Tensor) - The input tensor with shape :math:`(M, N, *)`
|
|
5579
|
-
where :math:`*` means any number of additional dimensions.
|
|
5580
|
-
|
|
5581
|
-
Outputs:
|
|
5582
|
-
Tensor, the same shape and data type as the input `x`.
|
|
5583
|
-
|
|
5584
|
-
Raises:
|
|
5585
|
-
TypeError: If `x` is not a Tensor.
|
|
5586
|
-
TypeError: If `diagonal` is not an int.
|
|
5587
|
-
ValueError: If the rank of `x` is less than 2.
|
|
5588
|
-
|
|
5589
|
-
Supported Platforms:
|
|
5590
|
-
``Ascend`` ``GPU`` ``CPU``
|
|
5591
|
-
|
|
5592
|
-
Examples:
|
|
5593
|
-
>>> import numpy as np
|
|
5594
|
-
>>> from mindspore import Tensor, ops
|
|
5595
|
-
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
|
5596
|
-
... [ 5, 6, 7, 8],
|
|
5597
|
-
... [10, 11, 12, 13],
|
|
5598
|
-
... [14, 15, 16, 17]]))
|
|
5599
|
-
>>> tril = ops.Tril()
|
|
5600
|
-
>>> result = tril(x)
|
|
5601
|
-
>>> print(result)
|
|
5602
|
-
[[ 1 0 0 0]
|
|
5603
|
-
[ 5 6 0 0]
|
|
5604
|
-
[10 11 12 0]
|
|
5605
|
-
[14 15 16 17]]
|
|
5606
|
-
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
|
5607
|
-
... [ 5, 6, 7, 8],
|
|
5608
|
-
... [10, 11, 12, 13],
|
|
5609
|
-
... [14, 15, 16, 17]]))
|
|
5610
|
-
>>> tril = ops.Tril(diagonal=1)
|
|
5611
|
-
>>> result = tril(x)
|
|
5612
|
-
>>> print(result)
|
|
5613
|
-
[[ 1 2 0 0]
|
|
5614
|
-
[ 5 6 7 0]
|
|
5615
|
-
[10 11 12 13]
|
|
5616
|
-
[14 15 16 17]]
|
|
5617
|
-
>>> x = Tensor(np.array([[ 1, 2, 3, 4],
|
|
5618
|
-
... [ 5, 6, 7, 8],
|
|
5619
|
-
... [10, 11, 12, 13],
|
|
5620
|
-
... [14, 15, 16, 17]]))
|
|
5621
|
-
>>> tril = ops.Tril(diagonal=-1)
|
|
5622
|
-
>>> result = tril(x)
|
|
5623
|
-
>>> print(result)
|
|
5624
|
-
[[ 0 0 0 0]
|
|
5625
|
-
[ 5 0 0 0]
|
|
5626
|
-
[10 11 0 0]
|
|
5627
|
-
[14 15 16 0]]
|
|
5628
|
-
"""
|
|
5629
|
-
|
|
5630
|
-
@prim_attr_register
|
|
5631
|
-
def __init__(self, diagonal=0):
|
|
5632
|
-
"""Initialize Tril."""
|
|
5633
|
-
self.init_prim_io_names(inputs=["x"], outputs=["y"])
|
|
5634
|
-
validator.check_value_type("diagonal", diagonal, [int], self.name)
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
5414
|
class IndexFill(Primitive):
|
|
5638
5415
|
"""
|
|
5639
5416
|
Fills the elements under the `dim` dimension of the input Tensor `x` with the input `value`
|
|
@@ -6338,7 +6115,8 @@ class TopK(Primitive):
|
|
|
6338
6115
|
- GPU: float16, float32.
|
|
6339
6116
|
- CPU: all numeric types.
|
|
6340
6117
|
|
|
6341
|
-
- **k** (int) - The number of top elements to be computed along the last dimension
|
|
6118
|
+
- **k** (Union(Tensor, int)) - The number of top elements to be computed along the last dimension.
|
|
6119
|
+
If `k` is a Tensor, the supported dtype is int32 and it should be 0-D or 1-D with shape :math:`(1, )` .
|
|
6342
6120
|
|
|
6343
6121
|
Outputs:
|
|
6344
6122
|
A tuple consisting of `values` and `indexes`.
|
|
@@ -53,14 +53,14 @@ class ReduceOp:
|
|
|
53
53
|
|
|
54
54
|
For the Ascend devices, users need to prepare the rank table, set rank_id and device_id.
|
|
55
55
|
Please see the `rank table Startup
|
|
56
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
56
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/rank_table.html>`_
|
|
57
57
|
for more details.
|
|
58
58
|
|
|
59
59
|
For the GPU devices, users need to prepare the host file and mpi, please see the `mpirun Startup
|
|
60
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
60
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/mpirun.html>`_ .
|
|
61
61
|
|
|
62
62
|
For the CPU device, users need to write a dynamic cluster startup script, please see the `Dynamic Cluster
|
|
63
|
-
Startup <https://www.mindspore.cn/tutorials/experts/en/
|
|
63
|
+
Startup <https://www.mindspore.cn/tutorials/experts/en/master/parallel/dynamic_cluster.html>`_ .
|
|
64
64
|
|
|
65
65
|
This example should be run with multiple devices.
|
|
66
66
|
|
|
@@ -144,14 +144,14 @@ class AllReduce(Primitive):
|
|
|
144
144
|
|
|
145
145
|
For the Ascend devices, users need to prepare the rank table, set rank_id and device_id.
|
|
146
146
|
Please see the `rank table Startup
|
|
147
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
147
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/rank_table.html>`_
|
|
148
148
|
for more details.
|
|
149
149
|
|
|
150
150
|
For the GPU devices, users need to prepare the host file and mpi, please see the `mpirun Startup
|
|
151
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
151
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/mpirun.html>`_ .
|
|
152
152
|
|
|
153
153
|
For the CPU device, users need to write a dynamic cluster startup script, please see the `Dynamic Cluster
|
|
154
|
-
Startup <https://www.mindspore.cn/tutorials/experts/en/
|
|
154
|
+
Startup <https://www.mindspore.cn/tutorials/experts/en/master/parallel/dynamic_cluster.html>`_ .
|
|
155
155
|
|
|
156
156
|
This example should be run with 2 devices.
|
|
157
157
|
|
|
@@ -180,7 +180,7 @@ class AllReduce(Primitive):
|
|
|
180
180
|
|
|
181
181
|
Tutorial Examples:
|
|
182
182
|
- `Distributed Set Communication Primitives - AllReduce
|
|
183
|
-
<https://www.mindspore.cn/docs/en/
|
|
183
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#allreduce>`_
|
|
184
184
|
|
|
185
185
|
"""
|
|
186
186
|
|
|
@@ -233,14 +233,14 @@ class AllGather(PrimitiveWithInfer):
|
|
|
233
233
|
|
|
234
234
|
For the Ascend devices, users need to prepare the rank table, set rank_id and device_id.
|
|
235
235
|
Please see the `rank table Startup
|
|
236
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
236
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/rank_table.html>`_
|
|
237
237
|
for more details.
|
|
238
238
|
|
|
239
239
|
For the GPU devices, users need to prepare the host file and mpi, please see the `mpirun Startup
|
|
240
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
240
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/mpirun.html>`_ .
|
|
241
241
|
|
|
242
242
|
For the CPU device, users need to write a dynamic cluster startup script, please see the `Dynamic Cluster
|
|
243
|
-
Startup <https://www.mindspore.cn/tutorials/experts/en/
|
|
243
|
+
Startup <https://www.mindspore.cn/tutorials/experts/en/master/parallel/dynamic_cluster.html>`_ .
|
|
244
244
|
|
|
245
245
|
This example should be run with 2 devices.
|
|
246
246
|
|
|
@@ -272,7 +272,7 @@ class AllGather(PrimitiveWithInfer):
|
|
|
272
272
|
|
|
273
273
|
Tutorial Examples:
|
|
274
274
|
- `Distributed Set Communication Primitives - AllGather
|
|
275
|
-
<https://www.mindspore.cn/docs/en/
|
|
275
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#allgather>`_
|
|
276
276
|
|
|
277
277
|
"""
|
|
278
278
|
|
|
@@ -458,14 +458,14 @@ class ReduceScatter(Primitive):
|
|
|
458
458
|
|
|
459
459
|
For the Ascend devices, users need to prepare the rank table, set rank_id and device_id.
|
|
460
460
|
Please see the `rank table Startup
|
|
461
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
461
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/rank_table.html>`_
|
|
462
462
|
for more details.
|
|
463
463
|
|
|
464
464
|
For the GPU devices, users need to prepare the host file and mpi, please see the `mpirun Startup
|
|
465
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
465
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/mpirun.html>`_ .
|
|
466
466
|
|
|
467
467
|
For the CPU device, users need to write a dynamic cluster startup script, please see the `Dynamic Cluster
|
|
468
|
-
Startup <https://www.mindspore.cn/tutorials/experts/en/
|
|
468
|
+
Startup <https://www.mindspore.cn/tutorials/experts/en/master/parallel/dynamic_cluster.html>`_ .
|
|
469
469
|
|
|
470
470
|
This example should be run with 2 devices.
|
|
471
471
|
|
|
@@ -498,7 +498,7 @@ class ReduceScatter(Primitive):
|
|
|
498
498
|
|
|
499
499
|
Tutorial Examples:
|
|
500
500
|
- `Distributed Set Communication Primitives - ReduceScatter
|
|
501
|
-
<https://www.mindspore.cn/docs/en/
|
|
501
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#reducescatter>`_
|
|
502
502
|
|
|
503
503
|
"""
|
|
504
504
|
|
|
@@ -600,14 +600,14 @@ class Broadcast(PrimitiveWithInfer):
|
|
|
600
600
|
|
|
601
601
|
For the Ascend devices, users need to prepare the rank table, set rank_id and device_id.
|
|
602
602
|
Please see the `rank table Startup
|
|
603
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
603
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/rank_table.html>`_
|
|
604
604
|
for more details.
|
|
605
605
|
|
|
606
606
|
For the GPU devices, users need to prepare the host file and mpi, please see the `mpirun Startup
|
|
607
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
607
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/mpirun.html>`_ .
|
|
608
608
|
|
|
609
609
|
For the CPU device, users need to write a dynamic cluster startup script, please see the `Dynamic Cluster
|
|
610
|
-
Startup <https://www.mindspore.cn/tutorials/experts/en/
|
|
610
|
+
Startup <https://www.mindspore.cn/tutorials/experts/en/master/parallel/dynamic_cluster.html>`_ .
|
|
611
611
|
|
|
612
612
|
This example should be run with multiple devices.
|
|
613
613
|
|
|
@@ -638,7 +638,7 @@ class Broadcast(PrimitiveWithInfer):
|
|
|
638
638
|
|
|
639
639
|
Tutorial Examples:
|
|
640
640
|
- `Distributed Set Communication Primitives - Broadcast
|
|
641
|
-
<https://www.mindspore.cn/docs/en/
|
|
641
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#broadcast>`_
|
|
642
642
|
|
|
643
643
|
"""
|
|
644
644
|
|
|
@@ -718,11 +718,11 @@ class NeighborExchange(Primitive):
|
|
|
718
718
|
The user needs to preset
|
|
719
719
|
communication environment variables before running the following example, please check the details on the
|
|
720
720
|
official website of `MindSpore \
|
|
721
|
-
<https://www.mindspore.cn/docs/en/
|
|
721
|
+
<https://www.mindspore.cn/docs/en/master/api_python/mindspore.ops.primitive.html#communication-operator>`_.
|
|
722
722
|
|
|
723
723
|
This operator requires a full-mesh network topology, each device has the same vlan id, and the ip & mask are
|
|
724
724
|
in the same subnet, please check the `details \
|
|
725
|
-
<https://www.mindspore.cn/docs/en/
|
|
725
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#notes>`_.
|
|
726
726
|
|
|
727
727
|
Args:
|
|
728
728
|
send_rank_ids (list(int)): Ranks which the data is sent to.
|
|
@@ -771,7 +771,7 @@ class NeighborExchange(Primitive):
|
|
|
771
771
|
|
|
772
772
|
Tutorial Examples:
|
|
773
773
|
- `Distributed Set Communication Primitives - NeighborExchange
|
|
774
|
-
<https://www.mindspore.cn/docs/en/
|
|
774
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#neighborexchange>`_
|
|
775
775
|
|
|
776
776
|
"""
|
|
777
777
|
|
|
@@ -804,7 +804,7 @@ class AlltoAll(PrimitiveWithInfer):
|
|
|
804
804
|
Note:
|
|
805
805
|
This operator requires a full-mesh network topology, each device has the same vlan id, and the ip & mask are
|
|
806
806
|
in the same subnet, please check the `details \
|
|
807
|
-
<https://www.mindspore.cn/docs/en/
|
|
807
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#notes>`_.
|
|
808
808
|
|
|
809
809
|
Args:
|
|
810
810
|
split_count (int): On each process, divide blocks into split_count number.
|
|
@@ -835,14 +835,14 @@ class AlltoAll(PrimitiveWithInfer):
|
|
|
835
835
|
|
|
836
836
|
For the Ascend devices, users need to prepare the rank table, set rank_id and device_id.
|
|
837
837
|
Please see the `rank table Startup
|
|
838
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
838
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/rank_table.html>`_
|
|
839
839
|
for more details.
|
|
840
840
|
|
|
841
841
|
For the GPU devices, users need to prepare the host file and mpi, please see the `mpirun Startup
|
|
842
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
842
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/mpirun.html>`_ .
|
|
843
843
|
|
|
844
844
|
For the CPU device, users need to write a dynamic cluster startup script, please see the `Dynamic Cluster
|
|
845
|
-
Startup <https://www.mindspore.cn/tutorials/experts/en/
|
|
845
|
+
Startup <https://www.mindspore.cn/tutorials/experts/en/master/parallel/dynamic_cluster.html>`_ .
|
|
846
846
|
|
|
847
847
|
This example should be run with 8 devices.
|
|
848
848
|
|
|
@@ -873,7 +873,7 @@ class AlltoAll(PrimitiveWithInfer):
|
|
|
873
873
|
|
|
874
874
|
Tutorial Examples:
|
|
875
875
|
- `Distributed Set Communication Primitives - AlltoAll
|
|
876
|
-
<https://www.mindspore.cn/docs/en/
|
|
876
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#alltoall>`_
|
|
877
877
|
|
|
878
878
|
"""
|
|
879
879
|
|
|
@@ -921,7 +921,7 @@ class NeighborExchangeV2(Primitive):
|
|
|
921
921
|
Note:
|
|
922
922
|
This operator requires a full-mesh network topology, each device has the same vlan id, and the ip & mask are
|
|
923
923
|
in the same subnet, please check the `details \
|
|
924
|
-
<https://www.mindspore.cn/docs/en/
|
|
924
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#notes>`_.
|
|
925
925
|
|
|
926
926
|
Args:
|
|
927
927
|
send_rank_ids (list(int)): Ranks which the data is sent to. 8 rank_ids represents 8 directions, if one
|
|
@@ -959,14 +959,14 @@ class NeighborExchangeV2(Primitive):
|
|
|
959
959
|
|
|
960
960
|
For the Ascend devices, users need to prepare the rank table, set rank_id and device_id.
|
|
961
961
|
Please see the `rank table Startup
|
|
962
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
962
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/rank_table.html>`_
|
|
963
963
|
for more details.
|
|
964
964
|
|
|
965
965
|
For the GPU devices, users need to prepare the host file and mpi, please see the `mpirun Startup
|
|
966
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
966
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/parallel/mpirun.html>`_ .
|
|
967
967
|
|
|
968
968
|
For the CPU device, users need to write a dynamic cluster startup script, please see the `Dynamic Cluster
|
|
969
|
-
Startup <https://www.mindspore.cn/tutorials/experts/en/
|
|
969
|
+
Startup <https://www.mindspore.cn/tutorials/experts/en/master/parallel/dynamic_cluster.html>`_ .
|
|
970
970
|
|
|
971
971
|
This example should be run with 2 devices.
|
|
972
972
|
|
|
@@ -1017,7 +1017,7 @@ class NeighborExchangeV2(Primitive):
|
|
|
1017
1017
|
|
|
1018
1018
|
Tutorial Examples:
|
|
1019
1019
|
- `Distributed Set Communication Primitives - NeighborExchangeV2
|
|
1020
|
-
<https://www.mindspore.cn/docs/en/
|
|
1020
|
+
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#neighborexchangev2>`_
|
|
1021
1021
|
|
|
1022
1022
|
"""
|
|
1023
1023
|
|
|
@@ -164,7 +164,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
164
164
|
function if needed. Then these `Custom` objects can be directly used in neural networks.
|
|
165
165
|
Detailed description and introduction of user-defined operators, including correct writing of parameters,
|
|
166
166
|
please refer to `Custom Operators Tutorial
|
|
167
|
-
<https://www.mindspore.cn/tutorials/experts/en/
|
|
167
|
+
<https://www.mindspore.cn/tutorials/experts/en/master/operation/op_custom.html>`_ .
|
|
168
168
|
|
|
169
169
|
.. warning::
|
|
170
170
|
- This is an experimental API that is subject to change.
|
|
@@ -172,19 +172,11 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
172
172
|
.. note::
|
|
173
173
|
The supported platforms are determined by the input `func_type`. The supported platforms are as follows:
|
|
174
174
|
|
|
175
|
-
- "hybrid": supports ["
|
|
176
|
-
- "akg": supports ["
|
|
177
|
-
- "tbe": supports ["Ascend"].
|
|
175
|
+
- "hybrid": supports ["GPU", "CPU"].
|
|
176
|
+
- "akg": supports ["GPU", "CPU"].
|
|
178
177
|
- "aot": supports ["GPU", "CPU"].
|
|
179
178
|
- "pyfunc": supports ["CPU"].
|
|
180
179
|
- "julia": supports ["CPU"].
|
|
181
|
-
- "aicpu": supports ["Ascend"].
|
|
182
|
-
|
|
183
|
-
If run on ge backend, use `CustomRegOp` to generate the registration information of "aicpu" and "tbe" operator,
|
|
184
|
-
use `custom_info_register` to bind the registration information to the `func` of the "tbe" operator,
|
|
185
|
-
then save the registration information of "aicpu" operator and the `func` implementation of "tbe" operator to
|
|
186
|
-
a file or separate files, keep these files in a separate directory, and set the absolute path of this directory
|
|
187
|
-
to environment variable "MS_DEV_CUSTOM_OPP_PATH" before running the network.
|
|
188
180
|
|
|
189
181
|
Args:
|
|
190
182
|
func (Union[function, str]):
|
|
@@ -193,9 +185,8 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
193
185
|
computation logic of a user defined operator. The function can be one of the following:
|
|
194
186
|
|
|
195
187
|
1. A AKG operator implementation function, which can use ir builder/tvm compute/hybrid grammar.
|
|
196
|
-
2. A
|
|
197
|
-
3.
|
|
198
|
-
4. An kernel decorated function written by the Hybrid DSL.
|
|
188
|
+
2. A pure python function
|
|
189
|
+
3. An kernel decorated function written by the Hybrid DSL.
|
|
199
190
|
|
|
200
191
|
- str: If func is of str type, then str should be a path of file along with a function name.
|
|
201
192
|
This could be used when func_type is "aot" or "julia".
|
|
@@ -299,18 +290,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
299
290
|
|
|
300
291
|
func_type (str): The implementation type of `func`, should be one of
|
|
301
292
|
|
|
302
|
-
[ ``"hybrid"`` , ``"akg"`` , ``"
|
|
303
|
-
|
|
304
|
-
Each `func_type` only supports specific platforms(targets). Default: ``"hybrid"`` .
|
|
305
|
-
The supported platforms of `func_type`:
|
|
306
|
-
|
|
307
|
-
- ``"hybrid"``: supports ["Ascend", "GPU", "CPU"].
|
|
308
|
-
- ``"akg"``: supports ["Ascend", "GPU", "CPU"].
|
|
309
|
-
- ``"tbe"``: supports ["Ascend"].
|
|
310
|
-
- ``"aot"``: supports ["GPU", "CPU"].
|
|
311
|
-
- ``"pyfunc"``: supports ["CPU"].
|
|
312
|
-
- ``"julia"``: supports ["CPU"].
|
|
313
|
-
- ``"aicpu"``: supports ["Ascend"].
|
|
293
|
+
[ ``"hybrid"`` , ``"akg"`` , ``"aot"`` , ``"pyfunc"`` , ``"julia"`` ].
|
|
314
294
|
|
|
315
295
|
bprop (function): The back propagation function of `func`. Default: ``None`` .
|
|
316
296
|
reg_info (Union[str, dict, list, tuple]): Represents the registration information(reg info) of `func` with
|
|
@@ -343,7 +323,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
343
323
|
or the attributes of `func` differs in different targets.
|
|
344
324
|
|
|
345
325
|
Supported Platforms:
|
|
346
|
-
``
|
|
326
|
+
``GPU`` ``CPU``
|
|
347
327
|
|
|
348
328
|
Examples:
|
|
349
329
|
>>> import numpy as np
|
|
@@ -372,68 +352,6 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
372
352
|
>>> # the result will be a 16 * 16 tensor with all elements 2
|
|
373
353
|
>>> print(output.shape)
|
|
374
354
|
(16, 16)
|
|
375
|
-
>>> # Example, func_type = "tbe"
|
|
376
|
-
>>> square_with_bias_op_info = CustomRegOp() \
|
|
377
|
-
... .fusion_type("OPAQUE") \
|
|
378
|
-
... .attr("bias", "required", "float") \
|
|
379
|
-
... .input(0, "x") \
|
|
380
|
-
... .output(0, "y") \
|
|
381
|
-
... .dtype_format(DataType.F32_Default, DataType.F32_Default) \
|
|
382
|
-
... .dtype_format(DataType.F16_Default, DataType.F16_Default) \
|
|
383
|
-
... .target("Ascend") \
|
|
384
|
-
... .get_op_info()
|
|
385
|
-
>>>
|
|
386
|
-
>>> @custom_info_register(square_with_bias_op_info)
|
|
387
|
-
... def square_with_bias(input_x, output_y, bias=0.0, kernel_name="square_with_bias"):
|
|
388
|
-
... import te.lang.cce
|
|
389
|
-
... from te import tvm
|
|
390
|
-
... from topi.cce import util
|
|
391
|
-
...
|
|
392
|
-
... shape = input_x.get("shape")
|
|
393
|
-
... dtype = input_x.get("dtype").lower()
|
|
394
|
-
...
|
|
395
|
-
... shape = util.shape_refine(shape)
|
|
396
|
-
... data = tvm.placeholder(shape, name="data", dtype=dtype)
|
|
397
|
-
...
|
|
398
|
-
... with tvm.target.cce():
|
|
399
|
-
... res0 = te.lang.cce.vmul(data, data)
|
|
400
|
-
... res = te.lang.cce.vadds(res0, bias)
|
|
401
|
-
... sch = te.lang.cce.auto_schedule(res)
|
|
402
|
-
...
|
|
403
|
-
... config = {"print_ir": False,
|
|
404
|
-
... "name": kernel_name,
|
|
405
|
-
... "tensor_list": [data, res]}
|
|
406
|
-
...
|
|
407
|
-
... te.lang.cce.cce_build_code(sch, config)
|
|
408
|
-
>>>
|
|
409
|
-
>>> def test_tbe():
|
|
410
|
-
... square_with_bias = ops.Custom(square_with_bias, out_shape=lambda x, _: x, \
|
|
411
|
-
... out_dtype=lambda x, _: x, func_type="tbe")
|
|
412
|
-
... res = self.square_with_bias(input_x, 1.0)
|
|
413
|
-
... return res
|
|
414
|
-
>>>
|
|
415
|
-
>>> # Example, func_type = "aicpu"
|
|
416
|
-
>>> resize_bilinear_op_info = CustomRegOp("ResizeBilinear") \
|
|
417
|
-
... .fusion_type("OPAQUE") \
|
|
418
|
-
... .input(0, "input", "required") \
|
|
419
|
-
... .output(1, "output", "required") \
|
|
420
|
-
... .attr("align_corners", "required", "bool") \
|
|
421
|
-
... .attr("cust_aicpu", "optional", "str", "aicpu_kernels") \
|
|
422
|
-
... .dtype_format(DataType.F32_Default, DataType.F32_Default) \
|
|
423
|
-
... .dtype_format(DataType.F16_Default, DataType.F32_Default) \
|
|
424
|
-
... .target("Ascend") \
|
|
425
|
-
... .get_op_info()
|
|
426
|
-
>>>
|
|
427
|
-
>>> @custom_info_register(resize_bilinear_op_info)
|
|
428
|
-
... def resize_bilinear_aicpu():
|
|
429
|
-
... return
|
|
430
|
-
>>>
|
|
431
|
-
>>> def test_aicpu(x):
|
|
432
|
-
... resize_bilinear_op = ops.Custom(resize_bilinear_aicpu, out_shape=[1, 1, 9, 9], \
|
|
433
|
-
... out_dtype=mstype.float32, func_type="aicpu")
|
|
434
|
-
... res = resize_bilinear_op(x, True, "aicpu_kernels")
|
|
435
|
-
... return res
|
|
436
|
-
>>>
|
|
437
355
|
>>> # Example, func_type = "aot"
|
|
438
356
|
>>> def test_aot(x, y, out_shapes, out_types):
|
|
439
357
|
... program = ops.Custom("./reorganize.so:CustomReorganize", out_shapes, out_types, "aot")
|