You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

array_ops.py 86 kB

4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
5 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
4 years ago
5 years ago
4 years ago
4 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
4 years ago
4 years ago
4 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
optimize the comment and log description 修改: ops/operations/_inner_ops.py 修改: ops/operations/_quant_ops.py 修改: ops/operations/array_ops.py 修改: ops/operations/comm_ops.py 修改: ops/operations/math_ops.py 修改: ops/operations/quantum_ops.py 修改: ops/operations/rl_ops.py 修改: ops/operations/sponge_ops.py 修改: ops/operations/sponge_update_ops.py 修改: train/__init__.py 修改: common/tensor.py 修改: train/serialization.py 修改: ccsrc/pipeline/jit/parse/parse.h 修改: explainer/benchmark/_attribution/metric.py 修改: ops/composite/multitype_ops/_constexpr_utils.py 修改: ops/operations/comm_ops.py 修改: RELEASE.md 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/concat_offset_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/dynamic_shape_cpu_kernel.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/reshape_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/tile_info.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/transpose_info.cc 修改: mindspore/ccsrc/frontend/parallel/strategy.h 修改: mindspore/common/tensor.py 修改: mindspore/core/abstract/prim_arrays.cc 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/core/ops/logical_and.h 修改: mindspore/core/ops/logical_not.h 修改: mindspore/core/ops/logical_or.h 修改: mindspore/core/ops/reduce_all.h 修改: mindspore/core/ops/reduce_any.h 修改: mindspore/lite/src/runtime/kernel/arm/fp32_grad/sgd.cc 修改: mindspore/nn/layer/quant.py 修改: mindspore/nn/optim/sgd.py 修改: mindspore/nn/sparse/sparse.py 修改: mindspore/numpy/array_creations.py 修改: mindspore/numpy/array_ops.py 修改: mindspore/numpy/logic_ops.py 修改: mindspore/numpy/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/train/_utils.py 修改: tests/ut/python/model/test_lenet_core_after_exception.py 修改: mindspore/_extends/parse/standard_method.py 修改: mindspore/ops/operations/rl_ops.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/core/ops/conv2d.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ctcloss_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_pull_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/fl/fused_push_weight_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_ftrl_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/ps/sparse_apply_lazy_adam_ps_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/rolling_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_arithmetic_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/split_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.h 修改: mindspore/ccsrc/backend/kernel_compiler/gpu/nn/conv2d_grad_input_gpu_kernel.h 修改: mindspore/ccsrc/fl/server/server.cc 修改: mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc 修改: mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h 修改: mindspore/ccsrc/frontend/optimizer/irpass/inline.h 修改: mindspore/ccsrc/minddata/dataset/core/device_tensor.cc 修改: mindspore/ccsrc/minddata/dataset/core/tensor.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/emnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/mnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/datasetops/source/qmnist_op.cc 修改: mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/dataset_node.cc 修改: mindspore/ccsrc/minddata/dataset/engine/opt/pre/epoch_ctrl_pass.cc 修改: mindspore/ccsrc/minddata/dataset/kernels/image/lite_image_utils.cc 修改: mindspore/ccsrc/pipeline/jit/action.cc 修改: mindspore/ccsrc/pipeline/jit/static_analysis/evaluator.cc 修改: mindspore/ccsrc/runtime/device/ascend/executor/tiling/op_tiling_adapter.cc 修改: mindspore/compression/quant/quant_utils.py 修改: mindspore/core/abstract/prim_nn.cc 修改: mindspore/dataset/engine/validators.py 修改: mindspore/lite/micro/coder/opcoders/nnacl/fp32/affine_fp32_coder.cc 修改: mindspore/lite/micro/coder/opcoders/nnacl/int8/affine_int8_coder.cc 修改: mindspore/lite/src/runtime/kernel/ascend310/src/custom_kernel.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/matmul.cc 修改: mindspore/lite/src/runtime/kernel/opencl/kernel/strassen.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/lite/tools/optimizer/fisson/fisson_util.cc 修改: mindspore/ops/composite/math_ops.py 修改: mindspore/ops/operations/_inner_ops.py 修改: mindspore/ops/operations/array_ops.py 修改: mindspore/ops/operations/math_ops.py 修改: mindspore/ops/operations/other_ops.py 修改: mindspore/boost/boost_cell_wrapper.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/update_cache_cpu_kernel.cc 修改: mindspore/ccsrc/common/trans.cc 修改: mindspore/ccsrc/frontend/parallel/cache_embedding/cache_embedding.cc 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/lite/src/common/log_util.h 修改: mindspore/nn/wrap/loss_scale.py 修改: mindspore/parallel/nn/moe.py 修改: tests/mindspore_test_framework/mindspore_test.py 修改: mindspore/ccsrc/backend/kernel_compiler/cpu/split_cpu_kernel.cc 修改: mindspore/lite/tools/common/graph_util.h 修改: mindspore/ccsrc/frontend/parallel/ops_info/gather_info.cc 修改: mindspore/core/ops/conv2d.cc 修改: tests/ut/python/model/test_lenet_core_after_exception.py
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506
  1. # Copyright 2020-2021 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """array operations, the function docs are adapted from Numpy API."""
  16. import operator
  17. from ..common import dtype as mstype
  18. from ..common import Tensor
  19. from ..ops import operations as P
  20. from ..ops import functional as F
  21. from ..ops.primitive import constexpr
  22. from ..nn import Cell
  23. from .utils import _convert_list_tensor_to_tuple_tensor, _expand, _broadcast_to_shape, \
  24. _check_input_tensor, _broadcast_to, _to_tensor, _callable
  25. from .utils_const import _check_axes_range, _check_start_normalize, \
  26. _raise_type_error, _raise_value_error, _infer_out_shape, _empty, _promote, \
  27. _check_same_type, _check_axis_valid, _add_unit_axes, _broadcast_tuples, \
  28. _check_is_float, _check_axis_in_range, _check_axis_type, _canonicalize_axis, \
  29. _list_comprehensions, _check_element_int, _is_shape_empty, _type_convert, \
  30. _tuple_slice, _expanded_shape, _seq_prod, _tuple_setitem, _iota, \
  31. _raise_unimplemented_error, _cumprod, _get_device, _check_is_int
  32. # According to official numpy reference, the dimension of a numpy array must be less
  33. # than 32
  34. MAX_NUMPY_DIMS = 32
  35. def expand_dims(a, axis):
  36. """
  37. Expands the shape of a tensor.
  38. Inserts a new axis that will appear at the axis position in the expanded tensor shape.
  39. Args:
  40. a (Tensor): Input tensor array.
  41. axis (Union[int, list(int), tuple(int)]): Position in the expanded axes where
  42. the new axis is placed,
  43. Returns:
  44. Tensor, with the number of dimensions increased at specified axis.
  45. Raises:
  46. TypeError: If input arguments have types not specified above.
  47. ValueError: If axis exceeds a.ndim.
  48. Supported Platforms:
  49. ``Ascend`` ``GPU`` ``CPU``
  50. Examples:
  51. >>> import mindspore.numpy as np
  52. >>> x = np.ones((2,2))
  53. >>> x = np.expand_dims(x,0)
  54. >>> print(x.shape)
  55. (1, 2, 2)
  56. """
  57. _check_input_tensor(a)
  58. if not isinstance(axis, (int, tuple, list)):
  59. _raise_type_error("axis must be tuple, list or int, but got ", axis)
  60. if isinstance(axis, int):
  61. return F.expand_dims(a, axis)
  62. ndim = a.ndim + len(axis)
  63. axis = _canonicalize_axis(axis, ndim)
  64. for ax in axis:
  65. a = F.expand_dims(a, ax)
  66. return a
  67. def squeeze(a, axis=None):
  68. """
  69. Removes single-dimensional entries from the shape of a tensor.
  70. Args:
  71. a (Tensor): Input tensor array.
  72. axis (Union[None, int, list(int), tuple(list)]): The axis(axes) to squeeze,
  73. default is None.
  74. Returns:
  75. Tensor, with all or a subset of the dimensions of length :math:`1` removed.
  76. Raises:
  77. TypeError: If input arguments have types not specified above.
  78. ValueError: If specified axis has shape entry :math:`> 1`.
  79. Supported Platforms:
  80. ``Ascend`` ``GPU`` ``CPU``
  81. Examples:
  82. >>> import mindspore.numpy as np
  83. >>> x = np.ones((1,2,2,1))
  84. >>> x = np.squeeze(x)
  85. >>> print(x.shape)
  86. (2, 2)
  87. """
  88. _check_input_tensor(a)
  89. return a.squeeze(axis)
  90. def transpose(a, axes=None):
  91. """
  92. Reverses or permutes the axes of a tensor; returns the modified tensor.
  93. Args:
  94. a (Tensor): a tensor to be transposed
  95. axes (Union[None, tuple, list]): the axes order, if `axes` is `None`, transpose
  96. the entire tensor. Default is `None`.
  97. Returns:
  98. Tensor, the transposed tensor array.
  99. Raises:
  100. TypeError: If input arguments have types not specified above.
  101. ValueError: If the number of `axes` is not euqal to a.ndim.
  102. Supported Platforms:
  103. ``Ascend`` ``GPU`` ``CPU``
  104. Examples:
  105. >>> import mindspore.numpy as np
  106. >>> x = np.ones((1,2,3))
  107. >>> x = np.transpose(x)
  108. >>> print(x.shape)
  109. (3, 2, 1)
  110. """
  111. _check_input_tensor(a)
  112. return a.transpose(axes)
  113. def rollaxis(x, axis, start=0):
  114. """
  115. Rolls the specified axis backwards, until it lies in the given position.
  116. The positions of the other axes do not change relative to one another.
  117. Args:
  118. x (Tensor): A Tensor to be transposed.
  119. axis (int): The axis to be rolled.
  120. start (int): Default: 0.
  121. If :math:`start <= axis`, the axis is rolled back until it lies in this position (`start`).
  122. If :math:`start > axis`: the axis is rolled until it lies before this position (`start`).
  123. If :math:`start < 0`, the start will be normalized as a non-negative number (more details
  124. can be seen in the source code.)
  125. .. table
  126. +===========+=================+
  127. |start |Normalized start |
  128. +===========+=================+
  129. |-(x.ndim+1)| raise ValueError|
  130. +-----------+-----------------+
  131. |-x.ndim |0 |
  132. +-----------+-----------------+
  133. |... |... |
  134. +-----------+-----------------+
  135. |-1 |x.ndim-1 |
  136. +-----------+-----------------+
  137. |... |... |
  138. +-----------+-----------------+
  139. |x.ndim |x.ndim |
  140. +-----------+-----------------+
  141. |x.ndim+1 |raise ValueError |
  142. +===========+=================+
  143. ..
  144. Returns:
  145. Transposed Tensor. Has the same data type as the original tensor `x`.
  146. Supported Platforms:
  147. ``Ascend`` ``GPU`` ``CPU``
  148. Raises:
  149. TypeError: If `axis` or `start` is not integer, or `x` is not tensor.
  150. ValueError: If `axis` is not in the range of :math:`[-ndim, ndim-1]` or
  151. `start` is not in the range of :math:`[-ndim, ndim]`.
  152. Examples:
  153. >>> import mindspore.numpy as np
  154. >>> x = np.ones((2,3,4))
  155. >>> output = np.rollaxis(x, 0, 2)
  156. >>> print(output.shape)
  157. (3, 2, 4)
  158. """
  159. _check_input_tensor(x)
  160. if not isinstance(axis, int):
  161. _raise_type_error("integer argument expected, but got ", axis)
  162. if not isinstance(start, int):
  163. _raise_type_error("integer argument expected, but got ", start)
  164. shape = F.shape(x)
  165. ndim = F.tuple_len(shape)
  166. axis = _check_axes_range(axis, ndim)
  167. start = _check_start_normalize(start, ndim)
  168. if start - axis >= 0 and start - axis <= 1:
  169. return x
  170. perm = F.make_range(0, ndim)
  171. new_perm = None
  172. if start < axis:
  173. if axis + 1 < ndim:
  174. new_perm = perm[0:start] + perm[axis:axis+1] + \
  175. perm[start:axis] + perm[axis+1:]
  176. else:
  177. new_perm = perm[0:start] + perm[axis:axis+1] + perm[start:axis]
  178. if start > axis:
  179. if start < ndim:
  180. new_perm = perm[0:axis] + perm[axis+1:start] + \
  181. perm[axis:axis+1] + perm[start:]
  182. else:
  183. new_perm = perm[0:axis] + perm[axis+1:start] + \
  184. perm[axis:axis+1]
  185. return F.transpose(x, new_perm)
  186. def swapaxes(x, axis1, axis2):
  187. """
  188. Interchanges two axes of a tensor.
  189. Args:
  190. x (Tensor): A tensor to be transposed.
  191. axis1 (int): First axis.
  192. axis2 (int): Second axis.
  193. Returns:
  194. Transposed tensor, has the same data type as the original tensor `x`.
  195. Raises:
  196. TypeError: If `axis1` or `axis2` is not integer, or `x` is not tensor.
  197. ValueError: If `axis1` or `axis2` is not in the range of :math:`[-ndim, ndim-1]`.
  198. Supported Platforms:
  199. ``Ascend`` ``GPU`` ``CPU``
  200. Examples:
  201. >>> import mindspore.numpy as np
  202. >>> x = np.ones((2,3,4))
  203. >>> output = np.swapaxes(x, 0, 2)
  204. >>> print(output.shape)
  205. (4,3,2)
  206. """
  207. _check_input_tensor(x)
  208. return x.swapaxes(axis1, axis2)
  209. def reshape(x, new_shape):
  210. """
  211. Reshapes a tensor without changing its data.
  212. Args:
  213. x (Tensor): A tensor to be reshaped.
  214. new_shape (Union[int, list(int), tuple(int)]): The new shape should be
  215. compatible with the original shape. If the tuple has only one element,
  216. the result will be a 1-D tensor of that length. One shape dimension
  217. can be :math:`-1`. In this case, the value is inferred from the length of
  218. the tensor and remaining dimensions.
  219. Returns:
  220. Reshaped Tensor. Has the same data type as the original tensor `x`.
  221. Raises:
  222. TypeError: If new_shape is not integer, list or tuple, or `x` is not tensor.
  223. ValueError: If new_shape is not compatible with the original shape.
  224. Supported Platforms:
  225. ``Ascend`` ``GPU`` ``CPU``
  226. Examples:
  227. >>> import mindspore.numpy as np
  228. >>> x = np.asarray([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]])
  229. >>> output = np.reshape(x, (3, 2))
  230. >>> print(output)
  231. [[-0.1 0.3]
  232. [ 3.6 0.4]
  233. [ 0.5 -3.2]]
  234. >>> output = np.reshape(x, (3, -1))
  235. >>> print(output)
  236. [[-0.1 0.3]
  237. [ 3.6 0.4]
  238. [ 0.5 -3.2]]
  239. >>> output = np.reshape(x, (6, ))
  240. >>> print(output)
  241. [-0.1 0.3 3.6 0.4 0.5 -3.2]
  242. """
  243. _check_input_tensor(x)
  244. return x.reshape(new_shape)
  245. def ravel(x):
  246. """
  247. Returns a contiguous flattened tensor.
  248. A 1-D tensor, containing the elements of the input, is returned.
  249. Args:
  250. x (Tensor): A tensor to be flattened.
  251. Returns:
  252. Flattened tensor, has the same data type as the original tensor `x`.
  253. Raises:
  254. TypeError: If `x` is not tensor.
  255. Supported Platforms:
  256. ``Ascend`` ``GPU`` ``CPU``
  257. Examples:
  258. >>> import mindspore.numpy as np
  259. >>> x = np.ones((2,3,4))
  260. >>> output = np.ravel(x)
  261. >>> print(output.shape)
  262. (24,)
  263. """
  264. _check_input_tensor(x)
  265. return x.ravel()
  266. @constexpr
  267. def _move_axes_for_concatenate(arr_shape, axis):
  268. """
  269. Moves axis 0 to the desiganated position, while keeps other axes' relative
  270. positions unchanged, only used if a single tensor is concatenated.
  271. """
  272. original_axes = tuple(range(len(arr_shape)))
  273. new_axes = original_axes[1:axis+1] + (0,) + original_axes[axis+1:]
  274. new_shape = arr_shape[1:axis+1] + (arr_shape[0] * arr_shape[axis+1],) + \
  275. arr_shape[axis+2:]
  276. return new_axes, new_shape
  277. def _promote_type_for_concatenate(tuple_of_tensors):
  278. """
  279. Checks dtype for all tensors in the tuple. If dtypes are not the same, promote
  280. them to the `highest` dtype in the tuple, so that they are ready for the concat
  281. operator.
  282. Args:
  283. tuple_of_tensors(tuple(tensor)): A tuple of tensors
  284. Returns:
  285. tuple of tensors, with each tensor promoted to ths same dtype.
  286. """
  287. need_cast = False
  288. final_type = tuple_of_tensors[0].dtype
  289. for tensor in tuple_of_tensors:
  290. if not _check_same_type(final_type, tensor.dtype):
  291. need_cast = True
  292. final_type = _promote(final_type, tensor.dtype)
  293. if not need_cast:
  294. return tuple_of_tensors
  295. tuple_of_casted_tensors = ()
  296. for tensor in tuple_of_tensors:
  297. tuple_of_casted_tensors += (tensor.astype(final_type, copy=False),)
  298. return tuple_of_casted_tensors
  299. def concatenate(arrays, axis=0):
  300. """
  301. Joins a sequence of tensors along an existing axis.
  302. Note:
  303. To match Numpy behaviour, :math:`axis >= 32` will not cause value error, the
  304. `axis` will be treated as :class:`None` instead.
  305. Args:
  306. arrays (Union[Tensor, tuple(Tensor), list(Tensor)]): a tensor or a list
  307. of tensors to be concatenated.
  308. axis (Union[None, int], optional): The axis along which the tensors will be joined,
  309. if `axis` is :class:`None`, tensors are flattened before use. Default is 0.
  310. Returns:
  311. A tensor concatenated from a tensor or a list of tensors.
  312. Raises:
  313. TypeError: If input arguments have types not specified above.
  314. ValueError: If `axis` is not in the range of :math:`[-ndim, ndim-1]`, and less than 32.
  315. Supported Platforms:
  316. ``Ascend`` ``GPU`` ``CPU``
  317. Examples:
  318. >>> import mindspore.numpy as np
  319. >>> x1 = np.ones((1,2,3))
  320. >>> x2 = np.ones((1,2,1))
  321. >>> x = np.concatenate((x1, x2), axis=-1)
  322. >>> print(x.shape)
  323. (1, 2, 4)
  324. """
  325. if isinstance(arrays, Tensor):
  326. # if only one tensor is provided, it is treated as a tuple along the
  327. # first dimension. For example, a tensor of shape (3,4,5) will be treated
  328. # as: tuple(tensor_1(4,5), tensor_2(4,5), tensor_3(4,5))
  329. if axis is None or axis >= MAX_NUMPY_DIMS:
  330. return ravel(arrays)
  331. arr_shape = F.shape(arrays)
  332. _check_axes_range((axis,), len(arr_shape))
  333. # move axis 0 to the disiganated position, while keep other axes' relative
  334. # positions unchanged
  335. new_axes, new_shape = _move_axes_for_concatenate(arr_shape, axis)
  336. arrays = transpose(arrays, new_axes)
  337. arrays = reshape(arrays, new_shape)
  338. return arrays
  339. flattened_arrays = ()
  340. if axis is None or axis >= MAX_NUMPY_DIMS:
  341. for arr in arrays:
  342. flattened_arrays += (ravel(arr),)
  343. axis = -1
  344. flattened_arrays = _promote_type_for_concatenate(flattened_arrays)
  345. return P.Concat(axis)(flattened_arrays)
  346. # convert a list of tensor to a tuple of tensor
  347. arrays = _convert_list_tensor_to_tuple_tensor(arrays)
  348. arr_shape = F.shape(arrays[0])
  349. _check_axes_range((axis,), len(arr_shape))
  350. # if only one tensor in the tuple/list, return the tensor itself
  351. if len(arrays) == 1:
  352. return arrays[0]
  353. arrays = _promote_type_for_concatenate(arrays)
  354. return P.Concat(axis)(arrays)
  355. def append(arr, values, axis=None):
  356. """
  357. Appends values to the end of a tensor.
  358. Args:
  359. arr (Tensor): Values are appended to a copy of this tensor.
  360. values (Tensor): These values are appended to a copy of `arr`. It must be of
  361. the correct shape (the same shape as `arr`, excluding `axis`). If `axis` is
  362. not specified, `values` can be any shape and will be flattened before use.
  363. axis (None, int, optional): The `axis` along which values are appended. If `axis` is not
  364. given, both `arr` and `values` are flattened before use, default is :class:`None`.
  365. Returns:
  366. Tensor, a copy of tensor with values appended to axis.
  367. Raises:
  368. TypeError: If input arguments have types not specified above.
  369. ValueError: If specified axis exceeds `arr.ndim`.
  370. Supported Platforms:
  371. ``Ascend`` ``GPU`` ``CPU``
  372. Examples:
  373. >>> import mindspore.numpy as np
  374. >>> a = np.ones((2, 3))
  375. >>> b = np.ones((2, 1))
  376. >>> print(np.append(a, b, axis=1).shape)
  377. (2, 4)
  378. """
  379. _check_input_tensor(arr)
  380. _check_input_tensor(values)
  381. if axis is None:
  382. arr = arr.ravel()
  383. values = values.ravel()
  384. else:
  385. _check_axis_in_range(axis, arr.ndim)
  386. if F.rank(arr) != F.rank(values):
  387. _raise_value_error("all tensors must have same number of dimensions")
  388. return concatenate((arr, values), axis)
  389. def column_stack(tup):
  390. """
  391. Stacks 1-D tensors as columns into a 2-D tensor. 2-D tensors are stacked as-is,
  392. like np.hstack.
  393. Args:
  394. tup (Union[Tensor, tuple, list]): A sequence of 1-D or 2-D tensors. All
  395. of them must have the same shape except the axis to be concatenated.
  396. Returns:
  397. 2-D Tensor, formed by stacking the given tensors.
  398. Supported Platforms:
  399. ``Ascend`` ``GPU`` ``CPU``
  400. Raises:
  401. TypeError: If `tup` is not Tensor, list or tuple.
  402. ValueError: If `tup` is empty.
  403. Examples:
  404. >>> import mindspore.numpy as np
  405. >>> x1 = np.array([1, 2, 3]).astype('int32')
  406. >>> x2 = np.array([4, 5, 6]).astype('int32')
  407. >>> output = np.column_stack((x1, x2))
  408. >>> print(output)
  409. [[1 4]
  410. [2 5]
  411. [3 6]]
  412. """
  413. if isinstance(tup, Tensor):
  414. return tup
  415. if not isinstance(tup, (list, tuple)):
  416. _raise_type_error("Tensor or, list or tuple of tensors are required, but got ", tup)
  417. trans_tup = ()
  418. for tensor in tup:
  419. if tensor.ndim < 1:
  420. tensor = F.expand_dims(tensor, 0)
  421. if tensor.ndim == 1:
  422. tensor = F.expand_dims(tensor, 1)
  423. trans_tup += (tensor,)
  424. if not trans_tup:
  425. _raise_value_error("Need at least one tensor to concatenate.")
  426. return P.Concat(1)(trans_tup)
  427. def vstack(tup):
  428. """
  429. Stacks tensors in sequence vertically.
  430. This is equivalent to concatenation along the first axis. 1-D tensors should firstly be reshaped to `(1, N)`,
  431. and then be concatenated along the first axis.
  432. Args:
  433. tup (Union[Tensor, tuple, list]): A sequence of 1-D or 2-D tensors. The tensors must have the same shape
  434. along all but the first axis. 1-D tensors must have the same shape.
  435. Returns:
  436. Stacked Tensor, formed by stacking the given tensors.
  437. Supported Platforms:
  438. ``Ascend`` ``GPU`` ``CPU``
  439. Raises:
  440. TypeError: If `tup` is not Tensor, list or tuple.
  441. ValueError: If `tup` is empty.
  442. Examples:
  443. >>> import mindspore.numpy as np
  444. >>> x1 = np.array([1, 2, 3]).astype('int32')
  445. >>> x2 = np.array([4, 5, 6]).astype('int32')
  446. >>> output = np.vstack((x1, x2))
  447. >>> print(output)
  448. [[1 2 3]
  449. [4 5 6]]
  450. """
  451. if isinstance(tup, Tensor):
  452. return tup
  453. if not isinstance(tup, (list, tuple)):
  454. _raise_type_error("Tensor or, list or tuple of tensors are required, but got", tup)
  455. trans_tup = ()
  456. for tensor in tup:
  457. if tensor.ndim <= 1:
  458. tensor = _expand(tensor, 2, 0)
  459. trans_tup += (tensor,)
  460. if not trans_tup:
  461. _raise_value_error("Need at least one tensor to concatenate.")
  462. return P.Concat(0)(trans_tup)
  463. def hstack(tup):
  464. """
  465. Stacks tensors in sequence horizontally.
  466. This is equivalent to concatenation along the second axis, except for 1-D tensors
  467. where it concatenates along the first axis.
  468. Args:
  469. tup (Union[Tensor, tuple, list]): A sequence of 1-D or 2-D tensors. The
  470. tensors must have the same shape along all but the second axis, except
  471. 1-D tensors which can be any length.
  472. Returns:
  473. Stacked Tensor, formed by stacking the given tensors.
  474. Supported Platforms:
  475. ``Ascend`` ``GPU`` ``CPU``
  476. Raises:
  477. TypeError: If `tup` is not Tensor, list or tuple.
  478. ValueError: If `tup` is empty.
  479. Examples:
  480. >>> import mindspore.numpy as np
  481. >>> x1 = np.array([1, 2, 3]).astype('float32')
  482. >>> x2 = np.array([4, 5, 6]).astype('float32')
  483. >>> output = np.hstack((x1, x2))
  484. >>> print(output)
  485. [1. 2. 3. 4. 5. 6.]
  486. """
  487. if isinstance(tup, Tensor):
  488. return tup
  489. if not isinstance(tup, (list, tuple)):
  490. _raise_type_error("Tensor or, list or tuple of tensors are required, but got", tup)
  491. tuple_of_tensor = ()
  492. for tensor in tup:
  493. if tensor.ndim < 1:
  494. tensor = F.expand_dims(tensor, 0)
  495. tuple_of_tensor += (tensor,)
  496. if not tuple_of_tensor:
  497. _raise_value_error("Need at least one tensor to concatenate.")
  498. if tuple_of_tensor[0].ndim <= 1:
  499. return P.Concat(0)(tuple_of_tensor)
  500. return P.Concat(1)(tuple_of_tensor)
  501. def dstack(tup):
  502. """
  503. Stacks tensors in sequence depth wise (along the third axis).
  504. This is equivalent to concatenation along the third axis. 1-D tensors :math:`(N,)` should be
  505. reshaped to :math:`(1,N,1)`.
  506. 2-D tensors :math:`(M,N)` should be reshaped to :math:`(M,N,1)` before concatenation.
  507. Args:
  508. tup (Union[Tensor, tuple, list]): A sequence of tensors. The tensors must have the same shape along all but
  509. the third axis. 1-D or 2-D tensors must have the same shape.
  510. Returns:
  511. Stacked Tensor, formed by stacking the given tensors.
  512. Supported Platforms:
  513. ``Ascend`` ``GPU`` ``CPU``
  514. Raises:
  515. TypeError: If `tup` is not Tensor, list or tuple.
  516. ValueError: If `tup` is empty.
  517. Examples:
  518. >>> import mindspore.numpy as np
  519. >>> x1 = np.array([1, 2, 3]).astype('float32')
  520. >>> x2 = np.array([4, 5, 6]).astype('float32')
  521. >>> output = np.dstack((x1, x2))
  522. >>> print(output)
  523. [[[1. 4.]
  524. [2. 5.]
  525. [3. 6.]]]
  526. """
  527. if isinstance(tup, Tensor):
  528. return tup
  529. if not isinstance(tup, (list, tuple)):
  530. _raise_type_error("Tensor or list or tuple of tensors are required, but got", tup)
  531. trans_tup = ()
  532. for tensor in tup:
  533. if tensor.ndim <= 1:
  534. tensor = _expand(tensor, 2, 0)
  535. if tensor.ndim == 2:
  536. tensor = F.expand_dims(tensor, 2)
  537. trans_tup += (tensor,)
  538. if not trans_tup:
  539. _raise_value_error("Need at least one tensor to concatenate.")
  540. return P.Concat(2)(trans_tup)
  541. def where(condition, x=None, y=None):
  542. """
  543. Returns elements chosen from `x` or `y` depending on `condition`.
  544. Note:
  545. As nonzero is not supported, both `x` and `y` must be provided Tensor
  546. input.
  547. Args:
  548. condition (Tensor): where True, yield `x`, otherwise yield `y`.
  549. x (Tensor): Values from which to choose. Defaults to None.
  550. y (Tensor): Values from which to choose. `x`, `y` and `condition` need
  551. to be broadcastable to some shape. Defaults to None.
  552. Returns:
  553. Tensor or scalar, with elements from `x` where `condition` is True, and
  554. elements from `y` elsewhere.
  555. Raises:
  556. ValueError: if operands cannot be broadcast.
  557. Supported Platforms:
  558. ``Ascend`` ``GPU`` ``CPU``
  559. Examples:
  560. >>> import mindspore.numpy as np
  561. >>> condition = np.full((1, 1, 2), [False, True])
  562. >>> x = np.full((1, 3, 2), 5)
  563. >>> y = np.full((2, 1, 1), 7)
  564. >>> output = np.where(condition, x, y)
  565. >>> print(output)
  566. [[[7 5]
  567. [7 5]
  568. [7 5]]
  569. [[7 5]
  570. [7 5]
  571. [7 5]]]
  572. """
  573. condition, x, y = _to_tensor(condition, x, y)
  574. # type promotes input tensors
  575. dtype1 = F.dtype(x)
  576. dtype2 = F.dtype(y)
  577. dtype = _promote(dtype1, dtype2)
  578. if not _check_same_type(dtype1, dtype):
  579. x = F.cast(x, dtype)
  580. if not _check_same_type(dtype2, dtype):
  581. y = F.cast(y, dtype)
  582. is_bool = _check_same_type(dtype1, mstype.bool_) and _check_same_type(
  583. dtype2, mstype.bool_)
  584. if is_bool:
  585. # select does not support bool type for x or y
  586. x = F.cast(x, mstype.float32)
  587. y = F.cast(y, mstype.float32)
  588. # broadcasts input tensors
  589. shape_out = _infer_out_shape(F.shape(condition),
  590. F.shape(x), F.shape(y))
  591. if not _check_same_type(F.dtype(condition), mstype.float32):
  592. # tiling with bool is not supported on GPU
  593. condition = F.cast(condition, mstype.float32)
  594. condition = _broadcast_to_shape(condition, shape_out)
  595. x = _broadcast_to_shape(x, shape_out)
  596. y = _broadcast_to_shape(y, shape_out)
  597. if not _check_same_type(F.dtype(condition), mstype.bool_):
  598. condition = F.cast(condition, mstype.bool_)
  599. res = F.select(condition, x, y)
  600. if is_bool:
  601. res = F.cast(res, mstype.bool_)
  602. return res
  603. def _atleast_xd(ndim, arys):
  604. """Returns arys with at least ndim."""
  605. _check_input_tensor(*arys)
  606. res = []
  607. for arr in arys:
  608. arr = _expand(arr, ndim)
  609. res.append(arr)
  610. if len(res) == 1:
  611. return res[0]
  612. return res
  613. def atleast_1d(*arys):
  614. """
  615. Converts inputs to arrays with at least one dimension.
  616. Scalar inputs are converted to 1-dimensional arrays, whilst
  617. higher-dimensional inputs are preserved.
  618. Note:
  619. In graph mode, returns a tuple of tensor instead of a list of
  620. tensors.
  621. Args:
  622. *arys (Tensor): one or more input tensors.
  623. Returns:
  624. Tensor, or list of tensors, each with ``a.ndim >= 1``.
  625. Raises:
  626. TypeError: if the input is not a tensor.
  627. Supported Platforms:
  628. ``Ascend`` ``GPU`` ``CPU``
  629. Examples:
  630. >>> import mindspore.numpy as np
  631. >>> a = np.ones((2, 3))
  632. >>> b = np.ones(())
  633. >>> c = np.ones(5)
  634. >>> output = np.atleast_1d(a, b, c)
  635. >>> print(output)
  636. [Tensor(shape=[2, 3], dtype=Float32, value=
  637. [[1.00000000e+00, 1.00000000e+00, 1.00000000e+00],
  638. [1.00000000e+00, 1.00000000e+00, 1.00000000e+00]]),
  639. Tensor(shape=[1], dtype=Float32, value= [1.00000000e+00]),
  640. Tensor(shape=[5], dtype=Float32,
  641. value= [1.00000000e+00, 1.00000000e+00, 1.00000000e+00,
  642. 1.00000000e+00, 1.00000000e+00])]
  643. """
  644. return _atleast_xd(1, arys)
  645. def atleast_2d(*arys):
  646. """
  647. Reshapes inputs as arrays with at least two dimensions.
  648. Note:
  649. In graph mode, returns a tuple of tensor instead of a list of
  650. tensors.
  651. Args:
  652. *arys (Tensor): one or more input tensors.
  653. Returns:
  654. Tensor, or list of tensors, each with ``a.ndim >= 2``.
  655. Raises:
  656. TypeError: if the input is not a tensor.
  657. Supported Platforms:
  658. ``Ascend`` ``GPU`` ``CPU``
  659. Examples:
  660. >>> import mindspore.numpy as np
  661. >>> a = np.ones((2, 3))
  662. >>> b = np.ones(())
  663. >>> c = np.ones(5)
  664. >>> output = np.atleast_2d(a, b, c)
  665. >>> print(output)
  666. [Tensor(shape=[2, 3], dtype=Float32, value=
  667. [[1.00000000e+00, 1.00000000e+00, 1.00000000e+00],
  668. [1.00000000e+00, 1.00000000e+00, 1.00000000e+00]]),
  669. Tensor(shape=[1, 1], dtype=Float32, value= [[1.00000000e+00]]),
  670. Tensor(shape=[1, 5], dtype=Float32,
  671. value= [[1.00000000e+00, 1.00000000e+00, 1.00000000e+00,
  672. 1.00000000e+00, 1.00000000e+00]])]
  673. """
  674. return _atleast_xd(2, arys)
  675. def atleast_3d(*arys):
  676. """
  677. Reshapes inputs as arrays with at least three dimensions.
  678. Note:
  679. In graph mode, returns a tuple of tensor instead of a list of
  680. tensors.
  681. Args:
  682. *arys (Tensor): one or more input tensors.
  683. Returns:
  684. Tensor, or list of tensors, each with ``a.ndim >= 3``. For example,
  685. a 1-D array of shape `(N,)` becomes a tensor of shape `(1, N, 1)`, and
  686. a 2-D array of shape `(M, N)` becomes a tensor of shape `(M, N, 1)`.
  687. Raises:
  688. TypeError: if the input is not a tensor.
  689. Supported Platforms:
  690. ``Ascend`` ``GPU`` ``CPU``
  691. Examples:
  692. >>> import mindspore.numpy as np
  693. >>> a = np.ones((2, 3))
  694. >>> b = np.ones(())
  695. >>> c = np.ones(5)
  696. >>> output = np.atleast_3d(a, b, c)
  697. >>> print(output)
  698. [Tensor(shape=[2, 3, 1], dtype=Float32, value=
  699. [[[1.00000000e+00], [1.00000000e+00], [1.00000000e+00]],
  700. [[1.00000000e+00], [1.00000000e+00], [1.00000000e+00]]]),
  701. Tensor(shape=[1, 1, 1], dtype=Float32, value= [[[1.00000000e+00]]]),
  702. Tensor(shape=[1, 5, 1], dtype=Float32,
  703. value= [[[1.00000000e+00], [1.00000000e+00], [1.00000000e+00],
  704. [1.00000000e+00], [1.00000000e+00]]])]
  705. """
  706. res = []
  707. for arr in arys:
  708. ndim = F.rank(arr)
  709. if ndim == 0:
  710. arr = F.reshape(arr, (1, 1, 1))
  711. elif ndim == 1:
  712. arr = F.reshape(arr, (1, F.size(arr), 1))
  713. elif ndim == 2:
  714. arr = F.reshape(arr, F.shape(arr) + (1,))
  715. res.append(arr)
  716. if len(res) == 1:
  717. return res[0]
  718. return res
  719. def stack(arrays, axis=0):
  720. """
  721. Joins a sequence of arrays along a new axis.
  722. The `axis` parameter specifies the index of the new axis in the
  723. dimensions of the result. For example, if ``axis=0`` it will be the
  724. first dimension and if ``axis=-1`` it will be the last dimension.
  725. Note:
  726. Numpy argument out is not supported.
  727. Args:
  728. arrays (sequence of Tensor): Each array must have the same shape.
  729. axis (int, optional): The axis in the result array along which the
  730. input arrays are stacked. Default: 0.
  731. Returns:
  732. Tensor, The stacked array has one more dimension than the input
  733. arrays.
  734. Raises:
  735. ValueError: if input is not Tensor, tuple, or list.
  736. Supported Platforms:
  737. ``Ascend`` ``GPU`` ``CPU``
  738. Examples:
  739. >>> import mindspore.numpy as np
  740. >>> arrays = [np.ones((3, 4)) for _ in range(10)]
  741. >>> output = np.stack(arrays, axis=0)
  742. >>> print(output.shape)
  743. (10, 3, 4)
  744. >>> output = np.stack(arrays, axis=1)
  745. >>> print(output.shape)
  746. (3, 10, 4)
  747. >>> output = np.stack(arrays, axis=2)
  748. >>> print(output.shape)
  749. (3, 4, 10)
  750. """
  751. if isinstance(arrays, Tensor):
  752. shape = F.shape(arrays)
  753. ndim = F.rank(arrays)
  754. axis = axis % ndim
  755. axes = F.make_range(ndim)
  756. perm = axes[1:axis+1] + (0,) + axes[axis+1:]
  757. if _is_shape_empty(shape):
  758. return _empty(mstype.float32, shape[1:axis+1] + (shape[0],) + shape[axis+1:])
  759. return transpose(arrays, perm)
  760. if isinstance(arrays, (list, tuple)):
  761. shape = (len(arrays),) + F.shape(arrays[0])
  762. ndim = len(shape)
  763. axis = axis % ndim
  764. if _is_shape_empty(shape):
  765. return _empty(mstype.float32, shape[1:axis+1] + (shape[0],) + shape[axis+1:])
  766. seq = ()
  767. for arr in arrays:
  768. seq += (F.expand_dims(arr, axis),)
  769. return concatenate(seq, axis)
  770. return _raise_value_error('input arrays must be Tensor, tuple, or list')
  771. class UniqueNet(Cell):
  772. """The operation is wrapped inside a model. """
  773. def __init__(self):
  774. super(UniqueNet, self).__init__()
  775. self.unique = P.Unique()
  776. def construct(self, x):
  777. return self.unique(x)
  778. def unique(x, return_inverse=False):
  779. """
  780. Finds the unique elements of a tensor. The input tensor will be flattened first
  781. when it has more than one dimension.
  782. Note:
  783. Numpy arguments `axis`, `return_index` and `return_counts` are not supported.
  784. On CPU, this operator must be executed in graph mode.
  785. Args:
  786. x (Tensor): The input tensor to be processed.
  787. return_inverse (bool): If `True`, also return the indices of the unique tensor.
  788. Default: `False`.
  789. Returns:
  790. Tensor or tuple of Tensors.
  791. - If `return_inverse` is `False`, just return the unique tensor.
  792. - If `return_inverse` is `True`, return tuple of tensors.
  793. Supported Platforms:
  794. ``Ascend`` ``GPU`` ``CPU``
  795. Raises:
  796. TypeError: If `x` is not tensor.
  797. Examples:
  798. >>> import mindspore.numpy as np
  799. >>> from mindspore import context
  800. >>> context.set_context(mode=context.GRAPH_MODE)
  801. >>> input_x = np.asarray([1, 2, 2, 2, 3, 4, 5]).astype('int32')
  802. >>> output_x = np.unique(input_x)
  803. >>> print(output_x)
  804. [1 2 3 4 5]
  805. >>> output_x = np.unique(input_x, return_inverse=True)
  806. >>> print(output_x)
  807. (Tensor(shape=[5], dtype=Int32, value= [ 1, 2, 3, 4, 5]), Tensor(shape=[7], dtype=Int32,
  808. value= [0, 1, 1, 1, 2, 3, 4]))
  809. """
  810. _check_input_tensor(x)
  811. if F.tuple_len(F.shape(x)) > 1:
  812. x = ravel(x)
  813. uniq = UniqueNet()
  814. res = uniq(x)
  815. if not return_inverse:
  816. return res[0]
  817. return res
  818. def roll_along_axis(a, shift, axis):
  819. """
  820. Rolls a tensor along a given axis. This is a helper function of np.roll.
  821. Args:
  822. a (Tensor): Input tensor.
  823. shift (int): The number of places the tensor is shifted.
  824. axis (int): The designated axis for shifting.
  825. Returns:
  826. Shifted tensor.
  827. """
  828. _check_axis_in_range(axis, a.ndim)
  829. _check_element_int((shift, axis))
  830. if axis < 0:
  831. axis += a.ndim
  832. shift = -(shift % a.shape[axis])
  833. # if shift is 0, we do not need to roll at all
  834. if shift == 0:
  835. return a
  836. begin1 = ()
  837. begin2 = ()
  838. end1 = ()
  839. end2 = ()
  840. stride = _list_comprehensions(a.ndim, 1, True)
  841. for i in F.make_range(a.ndim):
  842. if i != axis:
  843. begin1 += (0,)
  844. end1 += (a.shape[i],)
  845. begin2 += (0,)
  846. end2 += (a.shape[i],)
  847. else:
  848. begin1 += (shift,)
  849. end1 += (a.shape[i],)
  850. begin2 += (0,)
  851. end2 += (shift,)
  852. return append(F.strided_slice(a, begin1, end1, stride),
  853. F.strided_slice(a, begin2, end2, stride), axis=axis)
  854. def roll(a, shift, axis=None):
  855. """
  856. Rolls a tensor along given axes.
  857. Elements that rolls beyond the last position are re-introduced at the first.
  858. Args:
  859. a (Tensor): Input tensor.
  860. shift (Union[int, tuple(int)]: The number of places by which elements are
  861. shifted. If a tuple, then axis must be a tuple of the same size, and
  862. each of the given axes is shifted by the corresponding number. If shift
  863. is an int while axis is a tuple of integers, then the same value is used
  864. for all given axes.
  865. axis (Union[int, tuple(int)], optional): Axis or axes along which elements
  866. are shifted. By default, the array is flattened before shifting, after
  867. which the original shape is restored.
  868. Returns:
  869. Tensor, with the same shape as a.
  870. Supported Platforms:
  871. ``Ascend`` ``GPU`` ``CPU``
  872. Raises:
  873. TypeError: If input arguments have types not specified above.
  874. ValueError: If axis exceeds `a.ndim`, or `shift` and `axis` cannot broadcast.
  875. Examples:
  876. >>> import mindspore.numpy as np
  877. >>> a = np.reshape(np.arange(12), (3, 4))
  878. >>> print(np.roll(a, [2,-3], [0,-1]))
  879. [[ 7 4 5 6]
  880. [11 8 9 10]
  881. [ 3 0 1 2]]
  882. """
  883. _check_input_tensor(a)
  884. original_shape = a.shape
  885. original_dtype = a.dtype
  886. restore_shape = False
  887. # F.strided_slice only supports float on cpu, this will change once more supports
  888. # are added.
  889. if not _check_is_float(original_dtype):
  890. a = a.astype(mstype.float32)
  891. if axis is None:
  892. restore_shape = True
  893. axis = 0
  894. a = a.ravel()
  895. # Broadcast shift and axis to the same length
  896. shift, axis = _broadcast_tuples(shift, axis)
  897. for shift_each, axis_each in zip(shift, axis):
  898. a = roll_along_axis(a, shift_each, axis_each)
  899. if restore_shape:
  900. a = a.reshape(original_shape)
  901. if not _check_is_float(original_dtype):
  902. a = a.astype(original_dtype)
  903. return a
  904. @constexpr
  905. def _get_moved_perm(ndim, source, destination):
  906. """
  907. Helper function for moveaxis, returns permutation after moving axes
  908. from source to destination.
  909. """
  910. dest_sorted_idx = [i for i, _ in sorted(enumerate(destination),
  911. key=operator.itemgetter(1))]
  912. axes_orig = [i for i in range(ndim) if i not in source]
  913. k = 0
  914. m = 0
  915. perm = []
  916. for i in dest_sorted_idx:
  917. # inserts an axis that has been moved, denoted by n, and axes that remain
  918. # in their original position, indexed from k to k + n - m, into index m in
  919. # the list of permuted axes
  920. n = destination[i]
  921. j = k + n - m
  922. perm += axes_orig[k:j]
  923. perm.append(source[i])
  924. k += n - m
  925. m = n + 1
  926. perm += axes_orig[k:]
  927. return tuple(perm)
  928. @constexpr
  929. def _get_moved_shape(shape, perm):
  930. """
  931. Helper function for moveaxis, returns the permuated shape after
  932. applying perm.
  933. """
  934. return tuple([shape[i] for i in perm])
  935. def moveaxis(a, source, destination):
  936. """
  937. Moves axes of an array to new positions.
  938. Other axes remain in their original order.
  939. Args:
  940. a (Tensor): The array whose axes should be reordered.
  941. source (int or sequence of ints): Original positions of the
  942. axes to move. These must be unique.
  943. destination (int or sequence of ints): Destination positions
  944. for each of the original axes. These must also be unique.
  945. Returns:
  946. Tensor, array with moved axes.
  947. Raises:
  948. ValueError: if axes are out of the range of ``[-a.ndim, a.ndim)``, or
  949. if the axes contain duplicates.
  950. Supported Platforms:
  951. ``Ascend`` ``GPU`` ``CPU``
  952. Examples:
  953. >>> import mindspore.numpy as np
  954. >>> x = np.zeros((3, 4, 5))
  955. >>> output = np.moveaxis(x, 0, -1)
  956. >>> print(output.shape)
  957. (4, 5, 3)
  958. >>> output = np.moveaxis(x, -1, 0)
  959. >>> print(output.shape)
  960. (5, 3, 4)
  961. >>> output = np.moveaxis(x, [0, 1, 2], [-1, -2, -3])
  962. >>> print(output.shape)
  963. (5, 4, 3)
  964. """
  965. ndim = F.rank(a)
  966. source = _check_axis_valid(source, ndim)
  967. destination = _check_axis_valid(destination, ndim)
  968. if len(source) != len(destination):
  969. _raise_value_error('`source` and `destination` arguments must have the same number of elements')
  970. perm = _get_moved_perm(ndim, source, destination)
  971. shape = F.shape(a)
  972. if _is_shape_empty(shape):
  973. return _empty(F.dtype(a), _get_moved_shape(shape, perm))
  974. return F.transpose(a, perm)
  975. def tile(a, reps):
  976. """
  977. Constructs an array by repeating `a` the number of times given by `reps`.
  978. If `reps` has length `d`, the result will have dimension of ``max(d, a.ndim)``.
  979. If ``a.ndim < d``, `a` is promoted to be d-dimensional by prepending new axes.
  980. So a shape (3,) array is promoted to (1, 3) for 2-D replication, or
  981. shape (1, 1, 3) for 3-D replication. If this is not the desired behavior,
  982. promote `a` to d-dimensions manually before calling this function.
  983. If ``a.ndim > d``, `reps` is promoted to ``a.ndim`` by pre-pending 1's to it. Thus
  984. for an `a` of shape (2, 3, 4, 5), a `reps` of (2, 2) is treated as (1, 1, 2, 2).
  985. Args:
  986. a (Tensor): The input array.
  987. reps (int or sequence of ints): The number of repetitions of `a` along
  988. each axis.
  989. Returns:
  990. Tensor, the tiled output array.
  991. Raises:
  992. TypeError: if the input is not a tensor.
  993. Supported Platforms:
  994. ``Ascend`` ``GPU`` ``CPU``
  995. Examples:
  996. >>> import mindspore.numpy as np
  997. >>> a = np.array([0, 1, 2])
  998. >>> output = np.tile(a, 2)
  999. >>> print(output)
  1000. [0 1 2 0 1 2]
  1001. >>> output = np.tile(a, (2, 2))
  1002. >>> print(output)
  1003. [[0 1 2 0 1 2]
  1004. [0 1 2 0 1 2]]
  1005. >>> output = np.tile(a, (2, 1, 2))
  1006. >>> print(output)
  1007. [[[0 1 2 0 1 2]]
  1008. [[0 1 2 0 1 2]]]
  1009. """
  1010. _check_input_tensor(a)
  1011. ndim = F.rank(a)
  1012. shape = F.shape(a)
  1013. reps = _add_unit_axes(reps, ndim)
  1014. if _is_shape_empty(shape) or _is_shape_empty(reps):
  1015. shape = _add_unit_axes(shape, len(reps))
  1016. return _empty(F.dtype(a), _seq_prod(shape, reps))
  1017. return F.tile(a, reps)
  1018. @constexpr
  1019. def _check_can_broadcast_to(shape, target_shape):
  1020. """Determines if shape can be broadcast to target_shape."""
  1021. ndim = len(shape)
  1022. ndim_target = len(target_shape)
  1023. if ndim > ndim_target:
  1024. return False
  1025. for i, j in zip(reversed(shape), reversed(target_shape)):
  1026. if i not in (1, j):
  1027. return False
  1028. return True
  1029. def broadcast_to(array, shape):
  1030. """
  1031. Broadcasts an array to a new shape.
  1032. Args:
  1033. array (Tensor): The array to broadcast.
  1034. shape (tuple): The shape of the desired array.
  1035. Returns:
  1036. Tensor, original array broadcast to the given shape.
  1037. Raises:
  1038. ValueError: if array cannot be broadcast to shape.
  1039. Supported Platforms:
  1040. ``Ascend`` ``GPU`` ``CPU``
  1041. Example:
  1042. >>> import mindspore.numpy as np
  1043. >>> x = np.array([1, 2, 3])
  1044. >>> output = np.broadcast_to(x, (3, 3))
  1045. >>> print(output)
  1046. [[1 2 3]
  1047. [1 2 3]
  1048. [1 2 3]]
  1049. """
  1050. shape_a = F.shape(array)
  1051. if not _check_can_broadcast_to(shape_a, shape):
  1052. return _raise_value_error('cannot broadcast with ', shape)
  1053. return _broadcast_to_shape(array, shape)
  1054. def broadcast_arrays(*args):
  1055. """
  1056. Broadcasts any number of arrays against each other.
  1057. Note:
  1058. Numpy argument `subok` is not supported.
  1059. In graph mode, returns a tuple of Tensor instead of a list
  1060. of Tensor.
  1061. Args:
  1062. *args (Tensor): The arrays to broadcast.
  1063. Returns:
  1064. List of Tensor.
  1065. Raises:
  1066. ValueError: if arrays cannot be broadcast.
  1067. Supported Platforms:
  1068. ``Ascend`` ``GPU`` ``CPU``
  1069. Example:
  1070. >>> import mindspore.numpy as np
  1071. >>> x = np.array([[1,2,3]])
  1072. >>> y = np.array([[4],[5]])
  1073. >>> output = np.broadcast_arrays(x, y)
  1074. >>> print(output)
  1075. [Tensor(shape=[2, 3], dtype=Int32, value=
  1076. [[1, 2, 3],
  1077. [1, 2, 3]]), Tensor(shape=[2, 3], dtype=Int32, value=
  1078. [[4, 4, 4],
  1079. [5, 5, 5]])]
  1080. """
  1081. shapes = map(F.shape, args)
  1082. out_shape = _infer_out_shape(*shapes)
  1083. res = []
  1084. for arr in args:
  1085. res.append(broadcast_to(arr, out_shape))
  1086. return res
  1087. def array_split(x, indices_or_sections, axis=0):
  1088. """
  1089. Splits a tensor into multiple sub-tensors.
  1090. Note:
  1091. Currently, array_split only supports :class:`mindspore.float32` on ``CPU``.
  1092. The only difference between ``np.split`` and ``np.array_split`` is that
  1093. ``np.array_split`` allows indices_or_sections to be an integer that does not
  1094. equally divide the axis. For a tensor of length l that should be split into
  1095. n sections, it returns :math:`l % n` sub-arrays of size :math:`l//n + 1` and
  1096. the rest of size :math:`l//n`.
  1097. Args:
  1098. x (Tensor): A Tensor to be divided.
  1099. indices_or_sections (Union[int, tuple(int), list(int)]):
  1100. If integer, :math:`N`, the tensor will be divided into
  1101. :math:`N` tensors along axis.
  1102. If tuple(int), list(int) or of sorted integers,
  1103. the entries indicate where along axis the array is split.
  1104. For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
  1105. three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
  1106. If an index exceeds the dimension of the array along axis,
  1107. an empty sub-array is returned correspondingly.
  1108. axis (int): The axis along which to split. Default: 0.
  1109. Returns:
  1110. A list of sub-tensors.
  1111. Raises:
  1112. TypeError: If argument `indices_or_sections` is not integer,
  1113. tuple(int) or list(int) or argument `axis` is not integer.
  1114. ValueError: If argument `axis` is out of range of :math:`[-x.ndim, x.ndim)`.
  1115. Supported Platforms:
  1116. ``Ascend`` ``GPU`` ``CPU``
  1117. Examples:
  1118. >>> import mindspore.numpy as np
  1119. >>> input_x = np.arange(9).astype("float32")
  1120. >>> output = np.array_split(input_x, 4)
  1121. >>> print(output)
  1122. (Tensor(shape=[3], dtype=Float32,
  1123. value= [ 0.00000000e+00, 1.00000000e+00, 2.00000000e+00]),
  1124. Tensor(shape=[2], dtype=Float32,
  1125. value= [ 3.00000000e+00, 4.00000000e+00]),
  1126. Tensor(shape=[2], dtype=Float32,
  1127. value= [ 5.00000000e+00, 6.00000000e+00]),
  1128. Tensor(shape=[2], dtype=Float32,
  1129. value= [ 7.00000000e+00, 8.00000000e+00]))
  1130. """
  1131. return _split(x, indices_or_sections, opname="array_split", axis=axis)
  1132. def split(x, indices_or_sections, axis=0):
  1133. """
  1134. Splits a tensor into multiple sub-tensors along the given axis.
  1135. Args:
  1136. x (Tensor): A Tensor to be divided.
  1137. indices_or_sections (Union[int, tuple(int), list(int)]):
  1138. If integer, :math:`N`, the tensor will be divided into
  1139. :math:`N` equal tensors along axis.
  1140. If tuple(int), list(int) or of sorted integers,
  1141. the entries indicate where along axis the array is split.
  1142. For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
  1143. three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
  1144. If an index exceeds the dimension of the array along axis,
  1145. an empty sub-array is returned correspondingly.
  1146. axis (int): The axis along which to split. Default: 0.
  1147. Returns:
  1148. A list of sub-tensors.
  1149. Raises:
  1150. TypeError: If argument `indices_or_sections` is not integer,
  1151. tuple(int) or list(int) or argument `axis` is not integer.
  1152. ValueError: If argument `axis` is out of range of :math:`[-x.ndim, x.ndim)`.
  1153. Supported Platforms:
  1154. ``Ascend`` ``GPU`` ``CPU``
  1155. Examples:
  1156. >>> import mindspore.numpy as np
  1157. >>> input_x = np.arange(9).astype("float32")
  1158. >>> output = np.split(input_x, 3)
  1159. >>> print(output)
  1160. (Tensor(shape=[3], dtype=Float32,
  1161. value= [ 0.00000000e+00, 1.00000000e+00, 2.00000000e+00]),
  1162. Tensor(shape=[3], dtype=Float32,
  1163. value= [ 3.00000000e+00, 4.00000000e+00, 5.00000000e+00]),
  1164. Tensor(shape=[3], dtype=Float32,
  1165. value= [ 6.00000000e+00, 7.00000000e+00, 8.00000000e+00]))
  1166. """
  1167. return _split(x, indices_or_sections, opname="split", axis=axis)
  1168. def _split(x, indices_or_sections, opname, axis=0):
  1169. """Splits a tensor based on ``np.split`` or ``np.array_split``."""
  1170. _check_input_tensor(x)
  1171. _ = _check_axis_type(axis, True, False, False)
  1172. axis = _canonicalize_axis(axis, x.ndim)
  1173. res = None
  1174. arr_shape = x.shape
  1175. length_along_dim = arr_shape[axis]
  1176. if isinstance(indices_or_sections, int):
  1177. if indices_or_sections > length_along_dim:
  1178. _raise_value_error("empty tensor encountered.")
  1179. if opname == "split" or length_along_dim % indices_or_sections == 0:
  1180. res = P.Split(axis, indices_or_sections)(x)
  1181. else:
  1182. num_long_tensor = length_along_dim % indices_or_sections
  1183. num_short_tensor = indices_or_sections - num_long_tensor
  1184. length1 = num_long_tensor * (length_along_dim // indices_or_sections + 1)
  1185. length2 = length_along_dim - length1
  1186. start1 = _list_comprehensions(F.rank(x), 0, True)
  1187. size1 = _tuple_setitem(arr_shape, axis, length1)
  1188. start2 = _tuple_setitem(start1, axis, length1)
  1189. size2 = _tuple_setitem(arr_shape, axis, length2)
  1190. res = P.Split(axis, num_long_tensor)(F.tensor_slice(x, start1, size1)) + \
  1191. P.Split(axis, num_short_tensor)(F.tensor_slice(x, start2, size2))
  1192. elif isinstance(indices_or_sections, (list, tuple)) and _check_element_int(indices_or_sections):
  1193. res = _split_sub_tensors(x, indices_or_sections, axis)
  1194. else:
  1195. _raise_type_error("Argument `indices_or_sections` in `mindspore.numpy.split`\
  1196. should be integer, tuple(int) or list(int), but got", indices_or_sections)
  1197. return res
  1198. @constexpr
  1199. def convert_neg_indices(indices, ndim):
  1200. """converts negative values in tuple/list indices"""
  1201. def canonicalizer(ax):
  1202. return ax + ndim if ax < 0 else ax
  1203. indices = tuple([canonicalizer(axis) for axis in indices])
  1204. return indices
  1205. def _split_sub_tensors(x, indices, axis):
  1206. """
  1207. Splits the input tensor `x` into multiple sub-tensors
  1208. along the axis according to the given indices.
  1209. """
  1210. length_along_dim = x.shape[axis]
  1211. indices = convert_neg_indices(indices, length_along_dim)
  1212. indices += (length_along_dim,)
  1213. sub_tensors = []
  1214. strides = _list_comprehensions(x.ndim, 1, True)
  1215. begin = _list_comprehensions(x.ndim, 0)
  1216. end = _list_comprehensions(x.shape)
  1217. for i, idx in enumerate(indices):
  1218. begin[axis] = 0 if i == 0 else indices[i-1]
  1219. end[axis] = idx
  1220. if end[axis] <= begin[axis]:
  1221. _raise_value_error("empty sub-tensor encountered.")
  1222. sliced_tensor = F.strided_slice(x, _type_convert(tuple, begin), _type_convert(tuple, end), strides)
  1223. sub_tensors.append(sliced_tensor)
  1224. return sub_tensors
  1225. def vsplit(x, indices_or_sections):
  1226. """
  1227. Splits a tensor into multiple sub-tensors vertically (row-wise).
  1228. It is equivalent to split with :math:`axis=0` (default), the array is always
  1229. split along the first axis regardless of the array dimension.
  1230. Args:
  1231. x (Tensor): A Tensor to be divided.
  1232. indices_or_sections (Union[int, tuple(int), list(int)]):
  1233. If integer, :math:`N`, the tensor will be divided into
  1234. :math:`N` equal tensors along axis.
  1235. If tuple(int), list(int) or of sorted integers,
  1236. the entries indicate where along axis the array is split.
  1237. For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
  1238. three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
  1239. If an index exceeds the dimension of the array along axis,
  1240. an empty sub-array is returned correspondingly.
  1241. Returns:
  1242. A list of sub-tensors.
  1243. Raises:
  1244. TypeError: If argument `indices_or_sections` is not integer.
  1245. Supported Platforms:
  1246. ``Ascend`` ``GPU`` ``CPU``
  1247. Examples:
  1248. >>> import mindspore.numpy as np
  1249. >>> input_x = np.arange(9).reshape((3, 3)).astype('float32')
  1250. >>> output = np.vsplit(input_x, 3)
  1251. >>> print(output)
  1252. (Tensor(shape=[1, 3], dtype=Float32,
  1253. value=[[ 0.00000000e+00, 1.00000000e+00, 2.00000000e+00]]),
  1254. Tensor(shape=[1, 3], dtype=Float32,
  1255. value=[[ 3.00000000e+00, 4.00000000e+00, 5.00000000e+00]]),
  1256. Tensor(shape=[1, 3], dtype=Float32,
  1257. value=[[ 6.00000000e+00, 7.00000000e+00, 8.00000000e+00]]))
  1258. """
  1259. return split(x, indices_or_sections, 0)
  1260. def hsplit(x, indices_or_sections):
  1261. """
  1262. Splits a tensor into multiple sub-tensors horizontally (column-wise).
  1263. It is equivalent to split with :math:`axis=1` (default), the array is always
  1264. split along the second axis regardless of the array dimension.
  1265. Args:
  1266. x (Tensor): A Tensor to be divided.
  1267. indices_or_sections (Union[int, tuple(int), list(int)]):
  1268. If integer, :math:`N`, the tensor will be divided into
  1269. :math:`N` equal tensors along axis.
  1270. If tuple(int), list(int) or of sorted integers,
  1271. the entries indicate where along axis the array is split.
  1272. For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
  1273. three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
  1274. If an index exceeds the dimension of the array along axis,
  1275. an empty sub-array is returned correspondingly.
  1276. Returns:
  1277. A list of sub-tensors.
  1278. Raises:
  1279. TypeError: If argument `indices_or_sections` is not integer.
  1280. Supported Platforms:
  1281. ``Ascend`` ``GPU`` ``CPU``
  1282. Examples:
  1283. >>> import mindspore.numpy as np
  1284. >>> input_x = np.arange(6).reshape((2, 3)).astype('float32')
  1285. >>> output = np.hsplit(input_x, 3)
  1286. >>> print(output)
  1287. (Tensor(shape=[2, 1], dtype=Float32,
  1288. value=[[ 0.00000000e+00],
  1289. [ 3.00000000e+00]]),
  1290. Tensor(shape=[2, 1], dtype=Float32,
  1291. value=[[ 1.00000000e+00],
  1292. [ 4.00000000e+00]]),
  1293. Tensor(shape=[2, 1], dtype=Float32,
  1294. value=[[ 2.00000000e+00],
  1295. [ 5.00000000e+00]]))
  1296. """
  1297. return split(x, indices_or_sections, 1)
  1298. def dsplit(x, indices_or_sections):
  1299. """
  1300. Splits a tensor into multiple sub-tensors along the 3rd axis (depth).
  1301. It is equivalent to split with :math:`axis=2` (default), the array is always
  1302. split along the third axis regardless of the array dimension.
  1303. Args:
  1304. x (Tensor): A Tensor to be divided.
  1305. indices_or_sections (Union[int, tuple(int), list(int)]):
  1306. If integer, :math:`N`, the tensor will be divided into
  1307. :math:`N` equal tensors along axis.
  1308. If tuple(int), list(int) or of sorted integers,
  1309. the entries indicate where along axis the array is split.
  1310. For example, :math:`[2, 3]` would, for :math:`axis=0`, result in
  1311. three sub-tensors :math:`x[:2]`, :math:`x[2:3]`and :math:`x[3:]`.
  1312. If an index exceeds the dimension of the array along axis,
  1313. an empty sub-array is returned correspondingly.
  1314. Returns:
  1315. A list of sub-tensors.
  1316. Raises:
  1317. TypeError: If argument `indices_or_sections` is not integer.
  1318. Supported Platforms:
  1319. ``Ascend`` ``GPU`` ``CPU``
  1320. Examples:
  1321. >>> import mindspore.numpy as np
  1322. >>> input_x = np.arange(6).reshape((1, 2, 3)).astype('float32')
  1323. >>> output = np.dsplit(input_x, 3)
  1324. >>> print(output)
  1325. (Tensor(shape=[1, 2, 1], dtype=Float32,
  1326. value=[[[ 0.00000000e+00],
  1327. [ 3.00000000e+00]]]),
  1328. Tensor(shape=[1, 2, 1], dtype=Float32,
  1329. value=[[[ 1.00000000e+00],
  1330. [ 4.00000000e+00]]]),
  1331. Tensor(shape=[1, 2, 1], dtype=Float32,
  1332. value=[[[ 2.00000000e+00],
  1333. [ 5.00000000e+00]]]))
  1334. """
  1335. return split(x, indices_or_sections, 2)
  1336. @constexpr
  1337. def _get_flip_start(ndim, shape, axes):
  1338. return tuple([shape[i] - 1 if i in axes else 0 for i in range(ndim)])
  1339. @constexpr
  1340. def _get_flip_end(ndim, shape, axes):
  1341. return tuple([-shape[i] - 1 if i in axes else shape[i] + 1 for i in range(ndim)])
  1342. @constexpr
  1343. def _get_flip_strides(ndim, axes):
  1344. return tuple([-1 if i in axes else 1 for i in range(ndim)])
  1345. def flip(m, axis=None):
  1346. """
  1347. Reverses the order of elements in an array along the given axis.
  1348. The shape of the array is preserved, but the elements are reordered.
  1349. Args:
  1350. m (Tensor): Input array.
  1351. axis (None or int or tuple of integers, optional): Axis or axes along which
  1352. to flip over. The default, ``axis=None``, will flip over all of the axes
  1353. of the input array. If `axis` is negative it counts from the last to
  1354. the first axis. If `axis` is a tuple of integers, flipping is performed on
  1355. all of the axes specified in the tuple.
  1356. Returns:
  1357. Tensor, with the entries of `axis` reversed.
  1358. Raises:
  1359. TypeError: if the input is not a tensor.
  1360. Supported Platforms:
  1361. ``GPU`` ``CPU``
  1362. Example:
  1363. >>> import mindspore.numpy as np
  1364. >>> A = np.arange(8.0).reshape((2,2,2))
  1365. >>> output = np.flip(A)
  1366. >>> print(output)
  1367. [[[7. 6]
  1368. [5. 4]]
  1369. [[3. 2]
  1370. [1. 0]]]
  1371. >>> output = np.flip(A, (0, 2))
  1372. >>> print(output)
  1373. [[[5. 4]
  1374. [7. 6]]
  1375. [[1. 0]
  1376. [3. 2]]]
  1377. """
  1378. _check_input_tensor(m)
  1379. ndim = F.rank(m)
  1380. axes = _check_axis_valid(axis, ndim)
  1381. shape = F.shape(m)
  1382. dtype = F.dtype(m)
  1383. if _is_shape_empty(shape):
  1384. return m
  1385. if not _check_is_float(dtype):
  1386. m = m.astype(mstype.float32)
  1387. start = _get_flip_start(ndim, shape, axes)
  1388. end = _get_flip_end(ndim, shape, axes)
  1389. strides = _get_flip_strides(ndim, axes)
  1390. res = F.strided_slice(m, start, end, strides)
  1391. if not _check_same_type(F.dtype(res), dtype):
  1392. res = F.cast(res, dtype)
  1393. return res
  1394. def flipud(m):
  1395. """
  1396. Flips the entries in each column in the up/down direction.
  1397. Rows are preserved, but appear in a different order than before.
  1398. Args:
  1399. m (Tensor): Input array.
  1400. Returns:
  1401. Tensor.
  1402. Raises:
  1403. TypeError: if the input is not a tensor.
  1404. Supported Platforms:
  1405. ``GPU`` ``CPU``
  1406. Example:
  1407. >>> import mindspore.numpy as np
  1408. >>> A = np.arange(8.0).reshape((2,2,2))
  1409. >>> output = np.flipud(A)
  1410. >>> print(output)
  1411. [[[4. 5.]
  1412. [6. 7.]]
  1413. [[0. 1.]
  1414. [2. 3.]]]
  1415. """
  1416. return flip(m, 0)
  1417. def fliplr(m):
  1418. """
  1419. Flips the entries in each row in the left/right direction.
  1420. Columns are preserved, but appear in a different order than before.
  1421. Args:
  1422. m (Tensor): Input array.
  1423. Returns:
  1424. Tensor.
  1425. Raises:
  1426. TypeError: if the input is not a tensor.
  1427. Supported Platforms:
  1428. ``GPU`` ``CPU``
  1429. Example:
  1430. >>> import mindspore.numpy as np
  1431. >>> A = np.arange(8.0).reshape((2,2,2))
  1432. >>> output = np.fliplr(A)
  1433. >>> print(output)
  1434. [[[2. 3.]
  1435. [0. 1.]]
  1436. [[6. 7.]
  1437. [4. 5.]]]
  1438. """
  1439. return flip(m, 1)
  1440. def take_along_axis(arr, indices, axis):
  1441. """
  1442. Takes values from the input array by matching 1d index and data slices.
  1443. This iterates over matching 1d slices oriented along the specified axis in the
  1444. index and data arrays, and uses the former to look up values in the latter.
  1445. These slices can be different lengths.
  1446. Args:
  1447. arr (Tensor): Source array with shape `(Ni…, M, Nk…)`.
  1448. indices (Tensor): Indices with shape `(Ni…, J, Nk…)` to take along each 1d
  1449. slice of `arr`. This must match the dimension of `arr`, but dimensions `Ni`
  1450. and `Nj` only need to broadcast against `arr`.
  1451. axis (int): The axis to take 1d slices along. If `axis` is None, the input
  1452. array is treated as if it had first been flattened to 1d.
  1453. Returns:
  1454. Tensor, the indexed result, with shape `(Ni…, J, Nk…)`.
  1455. Raises:
  1456. ValueError: if input array and indices have different number of dimensions.
  1457. TypeError: if the input is not a Tensor.
  1458. Supported Platforms:
  1459. ``Ascend`` ``GPU`` ``CPU``
  1460. Example:
  1461. >>> import mindspore.numpy as np
  1462. >>> x = np.arange(12).reshape(3, 4)
  1463. >>> indices = np.arange(3).reshape(1, 3)
  1464. >>> output = np.take_along_axis(x, indices, 1)
  1465. >>> print(output)
  1466. [[ 0 1 2]
  1467. [ 4 5 6]
  1468. [ 8 9 10]]
  1469. """
  1470. _check_input_tensor(arr, indices)
  1471. if axis is None:
  1472. arr = ravel(arr)
  1473. axis = 0
  1474. ndim = F.rank(arr)
  1475. if ndim != F.rank(indices):
  1476. _raise_value_error('`indices` and `arr` must have the same number of dimensions')
  1477. axis = _check_axis_in_range(axis, ndim)
  1478. shape_arr = F.shape(arr)
  1479. shape_indices = F.shape(indices)
  1480. # broadcasts indices against the shape of arr except at axis
  1481. indices = _broadcast_to(indices, _tuple_slice(shape_indices, None, axis),
  1482. _tuple_slice(shape_arr, None, axis), ndim)
  1483. indices = _broadcast_to(indices, _tuple_slice(shape_arr, None, axis + 1) +
  1484. _tuple_slice(shape_indices, axis + 1, None), shape_arr, ndim)
  1485. return F.gather_d(arr, axis, indices)
  1486. def _mod(x, y):
  1487. """Computes x mod y."""
  1488. quotient = F.tensor_floordiv(x, y)
  1489. prod = F.tensor_mul(y, quotient)
  1490. return F.tensor_sub(x, prod)
  1491. def _check_indices(dims, indices, mode, allow_negative_index=True):
  1492. """Checks whether indices are out of bounds."""
  1493. shape = F.shape(indices)
  1494. dtype = F.dtype(indices)
  1495. if not allow_negative_index:
  1496. lowerbounds = F.fill(dtype, shape, 0)
  1497. else:
  1498. lowerbounds = F.fill(dtype, shape, -dims)
  1499. upperbounds = F.fill(dtype, shape, dims - 1)
  1500. out_of_lowerbounds = F.tensor_lt(indices, lowerbounds)
  1501. out_of_upperbounds = F.tensor_gt(indices, upperbounds)
  1502. if mode == 'raise':
  1503. _raise_unimplemented_error('"raise" mode is not implemented')
  1504. if mode == 'wrap':
  1505. return _mod(indices, F.fill(mstype.float32, shape, dims)).astype(dtype)
  1506. if mode != 'clip':
  1507. _raise_value_error('invalid mode. Expected "raise", "wrap", or "clip"')
  1508. zeros = F.fill(dtype, shape, 0)
  1509. clipped = F.select(out_of_lowerbounds, zeros, indices)
  1510. clipped = F.select(out_of_upperbounds, upperbounds, clipped)
  1511. return clipped
  1512. def take(a, indices, axis=None, mode='clip'):
  1513. """
  1514. Takes elements from an array along an axis.
  1515. When axis is not None, this function does the same thing as "fancy" indexing
  1516. (indexing arrays using arrays); however, it can be easier to use if you need
  1517. elements along a given axis. A call such as ``np.take(arr, indices, axis=3)`` is
  1518. equivalent to ``arr[:,:,:,indices,...]``.
  1519. Note:
  1520. Numpy argument out is not supported.
  1521. ``mode = 'raise'`` is not supported, and the default mode is 'clip' instead.
  1522. Args:
  1523. a (Tensor): Source array with shape `(Ni…, M, Nk…)`.
  1524. indices (Tensor): The indices with shape `(Nj...)` of the values to extract.
  1525. axis (int, optional): The axis over which to select values. By default,
  1526. the flattened input array is used.
  1527. mode ('raise', 'wrap', 'clip', optional): Specifies how out-of-bounds
  1528. indices will behave.
  1529. 'raise' – raise an error;
  1530. 'wrap' – wrap around;
  1531. 'clip' – clip to the range. 'clip' mode means that all indices that are
  1532. too large are replaced by the index that addresses the last element
  1533. along that axis. Note that this disables indexing with negative numbers.
  1534. Returns:
  1535. Tensor, the indexed result.
  1536. Raises:
  1537. ValueError: if axis is out of range.
  1538. TypeError: if the input is not a Tensor.
  1539. Supported Platforms:
  1540. ``Ascend`` ``GPU`` ``CPU``
  1541. Examples:
  1542. >>> import mindspore.numpy as np
  1543. >>> a = np.array([4, 3, 5, 7, 6, 8])
  1544. >>> indices = np.array([0, 1, 4])
  1545. >>> output = np.take(a, indices)
  1546. >>> print(output)
  1547. [4 3 6]
  1548. >>> indices = np.array([[0, 1], [2, 3]])
  1549. >>> output = np.take(a, indices)
  1550. >>> print(output)
  1551. [[4 3]
  1552. [5 7]]
  1553. """
  1554. _check_input_tensor(a, indices)
  1555. return a.take(indices, axis=axis, mode=mode)
  1556. def repeat(a, repeats, axis=None):
  1557. """
  1558. Repeats elements of an array.
  1559. Args:
  1560. a (Tensor): Input array.
  1561. repeats (int or sequence of ints): The number of repetitions for each element.
  1562. `repeats` is broadcasted to fit the shape of the given axis.
  1563. axis (int, optional): The axis along which to repeat values. By default,
  1564. use the flattened input array, and return a flat output array.
  1565. Returns:
  1566. Tensor, output array which has the same shape as `a`, except along the given
  1567. axis.
  1568. Raises:
  1569. ValueError: if axis is out of range.
  1570. TypeError: if input `a` is not a Tensor.
  1571. Supported Platforms:
  1572. ``Ascend`` ``GPU`` ``CPU``
  1573. Examples:
  1574. >>> import mindspore.numpy as np
  1575. >>> output = np.repeat(np.array(3), 4)
  1576. >>> print(output)
  1577. [3 3 3 3]
  1578. >>> x = np.array([[1,2],[3,4]])
  1579. >>> output = np.repeat(x, 2)
  1580. >>> print(output)
  1581. [1 1 2 2 3 3 4 4]
  1582. >>> output = np.repeat(x, 3, axis=1)
  1583. >>> print(output)
  1584. [[1 1 1 2 2 2]
  1585. [3 3 3 4 4 4]]
  1586. >>> output = np.repeat(x, [1, 2], axis=0)
  1587. >>> print(output)
  1588. [[1 2]
  1589. [3 4]
  1590. [3 4]]
  1591. """
  1592. a = _to_tensor(a)
  1593. return a.repeat(repeats, axis)
  1594. def rot90(a, k=1, axes=(0, 1)):
  1595. """
  1596. Rotates a tensor by 90 degrees in the plane specified by axes.
  1597. Rotation direction is from the first towards the second axis.
  1598. Args:
  1599. a (Tensor): Input tensor of two or more dimensions.
  1600. k (int): Number of times the tensor is rotated by 90 degrees. Default: 1.
  1601. axes (Union[tuple(int), list(int)]): The tensor is rotated in the plane
  1602. defined by the axes. Default: `(0, 1)`.
  1603. Axes must be different and with the shape of `(2,)`.
  1604. Returns:
  1605. Tensor.
  1606. Raises:
  1607. TypeError: if input `a` is not a Tensor or
  1608. the argument `k` is not integer or
  1609. the argument `axes` is not tuple of integers or list of ints.
  1610. ValueError: if any axis is out of range or
  1611. the length of `axes` is not `2`.
  1612. Supported Platforms:
  1613. ``GPU``
  1614. Examples:
  1615. >>> import mindspore.numpy as np
  1616. >>> a = np.arange(24).reshape((2, 3, 4))
  1617. >>> output = np.rot90(a)
  1618. >>> print(output)
  1619. [[[ 8 9 10 11]
  1620. [20 21 22 23]]
  1621. [[ 4 5 6 7]
  1622. [16 17 18 19]]
  1623. [[ 0 1 2 3]
  1624. [12 13 14 15]]]
  1625. >>> output = np.rot90(a, 3, (1, 2))
  1626. >>> print(output)
  1627. [[[ 8 4 0]
  1628. [ 9 5 1]
  1629. [10 6 2]
  1630. [11 7 3]]
  1631. [[20 16 12]
  1632. [21 17 13]
  1633. [22 18 14]
  1634. [23 19 15]]]
  1635. """
  1636. _check_input_tensor(a)
  1637. if not isinstance(k, int):
  1638. _raise_type_error("integer argument expected, but got ", k)
  1639. k = k % 4 if k >= 0 else 4 - (-k % 4)
  1640. if not isinstance(axes, (tuple, list)):
  1641. _raise_type_error("tuple(ints) or list(ints) expected, but got ", axes)
  1642. if len(axes) != 2:
  1643. _raise_value_error("len(axes) must be 2.")
  1644. axis1, axis2 = axes[0], axes[1]
  1645. axis1 = _canonicalize_axis(axis1, a.ndim)
  1646. axis2 = _canonicalize_axis(axis2, a.ndim)
  1647. if axis1 == axis2:
  1648. _raise_value_error('Axes must be different.')
  1649. if k == 0:
  1650. return a
  1651. if k == 2:
  1652. return flip(flip(a, axis1), axis2)
  1653. perm = _list_comprehensions(a.ndim)
  1654. perm[axis1], perm[axis2] = perm[axis2], perm[axis1]
  1655. if k == 1:
  1656. return flip(transpose(a, perm), axis1)
  1657. return flip(transpose(a, perm), axis2)
  1658. def select(condlist, choicelist, default=0):
  1659. """
  1660. Returns an array drawn from elements in `choicelist`, depending on conditions.
  1661. Args:
  1662. condlist (Union[int, float, bool, list, tuple, Tensor]): The list of conditions
  1663. which determine from which array in `choicelist` the output elements are
  1664. taken. When multiple conditions are satisfied, the first one encountered in
  1665. `condlist` is used.
  1666. choicelist (Union[int, float, bool, list, tuple, Tensor]): The list of arrays
  1667. from which the output elements are taken. It has to be of the same length as
  1668. `condlist`.
  1669. default (scalar, optional): The element inserted in output when all conditions
  1670. evaluate to `False`. Defaults to 0.
  1671. Returns:
  1672. Tensor, the output at position `m` is the `m-th` element of the array in
  1673. `choicelist` where the `m-th` element of the corresponding array in `condlist`
  1674. is `True`.
  1675. Raises:
  1676. ValueError: if ``len(condlist) != len(choicelist)``.
  1677. Supported Platforms:
  1678. ``Ascend`` ``GPU`` ``CPU``
  1679. Examples:
  1680. >>> import mindspore.numpy as np
  1681. >>> condlist = [[True, True, True, False, False], [False, False, True, False, True]]
  1682. >>> choicelist = [[0, 1, 2, 3, 4], [0, 1, 4, 9, 16]]
  1683. >>> output = np.select(condlist, choicelist)
  1684. >>> print(output)
  1685. [ 0 1 2 0 16]
  1686. """
  1687. condlist, choicelist = _to_tensor(condlist, choicelist)
  1688. shape_cond = F.shape(condlist)
  1689. shape_choice = F.shape(choicelist)
  1690. if F.rank(condlist) == 0 or F.rank(choicelist) == 0:
  1691. _raise_value_error('input cannot be scalars')
  1692. case_num = shape_cond[0]
  1693. if shape_choice[0] != case_num:
  1694. _raise_value_error('list of cases must be same length as list of conditions')
  1695. case_size_cond = _tuple_slice(shape_cond, 1, None)
  1696. case_size_choice = _tuple_slice(shape_choice, 1, None)
  1697. # performs broadcast over the cases in condlist and choicelist
  1698. case_size = _infer_out_shape(case_size_cond, case_size_choice)
  1699. shape_broadcasted = (case_num,) + case_size
  1700. ndim = len(shape_broadcasted)
  1701. shape_cond_expanded = ((case_num,) + _list_comprehensions(ndim - F.rank(condlist), 1, True) +
  1702. case_size_cond)
  1703. condlist = _broadcast_to_shape(F.reshape(condlist, shape_cond_expanded), shape_broadcasted)
  1704. shape_choice_expanded = ((case_num,) + _list_comprehensions(ndim - F.rank(choicelist), 1, True) +
  1705. case_size_choice)
  1706. choicelist = _broadcast_to_shape(F.reshape(choicelist, shape_choice_expanded), shape_broadcasted)
  1707. slice_start = _list_comprehensions(ndim - 1, 0, True)
  1708. slice_size = (1,) + case_size
  1709. dtype = F.dtype(choicelist)
  1710. if isinstance(default, Tensor):
  1711. default_slice = default.astype(F.dtype(choicelist)).reshape(slice_size)
  1712. else:
  1713. default_slice = F.fill(F.dtype(choicelist), slice_size, default)
  1714. for i in range(case_num - 1, -1, -1):
  1715. cond_slice = F.tensor_slice(condlist.astype(mstype.float32), (i,) + slice_start, slice_size)
  1716. choice_slice = F.tensor_slice(choicelist, (i,) + slice_start, slice_size)
  1717. default_slice = F.select(cond_slice.astype(mstype.bool_), choice_slice, default_slice)
  1718. return F.reshape(default_slice, (case_size)).astype(dtype)
  1719. @constexpr
  1720. def _get_grid(shape):
  1721. """Returns a grid representing all the indices for an array with the given shape."""
  1722. grids = []
  1723. ndim = len(shape)
  1724. for i in range(ndim):
  1725. dim_grid = _iota(mstype.int32, shape[i])
  1726. dim_shape = _expanded_shape(ndim, shape[i], i)
  1727. dim_grid = _broadcast_to_shape(dim_grid.reshape(dim_shape), shape)
  1728. grids.append(dim_grid)
  1729. return stack(grids, -1)
  1730. def choose(a, choices, mode='clip'):
  1731. """
  1732. Construct an array from an index array and a list of arrays to choose from.
  1733. Given an "index" array `a` of integers and a sequence of n arrays (choices),
  1734. `a` and each choice array are first broadcast, as necessary, to arrays of a
  1735. common shape; calling these `Ba` and `Bchoices[i], i = 0,…,n-1` we have that,
  1736. necessarily, ``Ba.shape == Bchoices[i].shape`` for each `i`. Then, a new array
  1737. with ``shape Ba.shape`` is created as follows:
  1738. - if ``mode='raise'`` (the default), then, first of all, each element of `a`
  1739. (and thus `Ba`) must be in the range `[0, n-1]`; now, suppose that `i`
  1740. (in that range) is the value at the `(j0, j1, ..., jm)` position in
  1741. `Ba` - then the value at the same position in the new array is the
  1742. value in ``Bchoices[i]`` at that same position;
  1743. - if ``mode='wrap'``, values in `a` (and thus `Ba`) may be any (signed)
  1744. integer; modular arithmetic is used to map integers outside the
  1745. range ``[0, n-1]`` back into that range; and then the new array is
  1746. constructed as above;
  1747. - if ``mode='clip'``, values in `a` (and thus `Ba`) may be any (signed) integer;
  1748. negative integers are mapped to 0; values greater than `n-1` are mapped to
  1749. `n-1`; and then the new array is constructed as above.
  1750. Note:
  1751. Numpy argument `out` is not supported.
  1752. ``mode = 'raise'`` is not supported, and the default mode is 'clip' instead.
  1753. Args:
  1754. a (int array): This array must contain integers in ``[0, n-1]``, where `n` is
  1755. the number of choices, unless ``mode=wrap`` or ``mode=clip``, in which
  1756. cases any integers are permissible.
  1757. choices (sequence of arrays): Choice arrays. `a` and all of the `choices` must
  1758. be broadcastable to the same shape. If `choices` is itself an array, then
  1759. its outermost dimension (i.e., the one corresponding to ``choices.shape[0]``)
  1760. is taken as defining the "sequence".
  1761. mode ('raise', 'wrap', 'clip', optional): Specifies how indices outside
  1762. ``[0, n-1]`` will be treated:
  1763. 'raise' – raise an error;
  1764. 'wrap' – wrap around;
  1765. 'clip' – clip to the range. 'clip' mode means that all indices that are
  1766. too large are replaced by the index that addresses the last element
  1767. along that axis. Note that this disables indexing with negative numbers.
  1768. Returns:
  1769. Tensor, the merged result.
  1770. Raises:
  1771. ValueError: if `a` and any of the `choices` cannot be broadcast.
  1772. Supported Platforms:
  1773. ``Ascend`` ``GPU`` ``CPU``
  1774. Examples:
  1775. >>> import mindspore.numpy as np
  1776. >>> choices = [[0, 1, 2, 3], [10, 11, 12, 13], [20, 21, 22, 23], [30, 31, 32, 33]]
  1777. >>> print(np.choose([2, 3, 1, 0], choices))
  1778. [20 31 12 3]
  1779. >>> print(np.choose([2, 4, 1, 0], choices, mode='clip'))
  1780. [20 31 12 3]
  1781. >>> print(np.choose([2, 4, 1, 0], choices, mode='wrap'))
  1782. [20 1 12 3]
  1783. >>> a = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]
  1784. >>> choices = [-10, 10]
  1785. >>> print(np.choose(a, choices))
  1786. [[ 10 -10 10]
  1787. [-10 10 -10]
  1788. [ 10 -10 10]]
  1789. """
  1790. a = _to_tensor(a)
  1791. if not _check_is_int(F.dtype(a)):
  1792. _raise_value_error('`a` should be an int array')
  1793. if isinstance(choices, (tuple, list)):
  1794. # broadcasts choices to the same shape if choices is a sequence
  1795. choices = _to_tensor(*choices)
  1796. shapes = ()
  1797. for choice in choices:
  1798. shapes += (F.shape(choice),)
  1799. shape_choice = _infer_out_shape(F.shape(a), *shapes)
  1800. tmp = []
  1801. for choice in choices:
  1802. tmp.append(broadcast_to(choice, shape_choice))
  1803. choices = stack(tmp)
  1804. else:
  1805. choices = _to_tensor(choices)
  1806. shape_choice = _infer_out_shape(F.shape(a), F.shape(choices)[1:])
  1807. choices = F.reshape(choices, choices.shape[:1] + _add_unit_axes(choices.shape[1:], len(shape_choice)))
  1808. choices = broadcast_to(choices, (F.shape(choices)[0],) + shape_choice)
  1809. if F.rank(a) == 0 or F.rank(choices) == 0:
  1810. _raise_value_error('input cannot be scalars')
  1811. a = broadcast_to(a, shape_choice)
  1812. a = _check_indices(F.shape(choices)[0], a, mode, allow_negative_index=False)
  1813. grid = _get_grid(F.shape(a))
  1814. indices = concatenate((a.reshape(F.shape(a) + (1,)), grid), -1)
  1815. return F.gather_nd(choices, indices)
  1816. def size(a, axis=None):
  1817. """
  1818. Returns the number of elements along a given axis.
  1819. Args:
  1820. a (Union[int, float, bool, list, tuple, Tensor]): Input data.
  1821. axis (int): Axis along which the elements are counted. Default: None.
  1822. If None, give the total number of elements.
  1823. Returns:
  1824. Number of elements along the specified axis.
  1825. Supported Platforms:
  1826. ``Ascend`` ``GPU`` ``CPU``
  1827. Raises:
  1828. TypeError: If input is not array_like or `axis` is not int.
  1829. ValueError: If any axis is out of range or duplicate axes exist.
  1830. Examples:
  1831. >>> import mindspore.numpy as np
  1832. >>> x = np.arange(10).reshape(2, 5).astype('float32')
  1833. >>> print(np.size(x))
  1834. 10
  1835. >>> print(np.size(x, axis=1))
  1836. 5
  1837. """
  1838. a = _to_tensor(a)
  1839. if axis is None:
  1840. return a.size
  1841. if not isinstance(axis, int):
  1842. _raise_type_error("axis argument should be integer.")
  1843. axis = _canonicalize_axis(axis, a.ndim)
  1844. return a.shape[axis]
  1845. def array_str(a):
  1846. """
  1847. Returns a string representation of the data in an array.
  1848. The data in the array is returned as a single string.
  1849. This function is similar to array_repr, the difference being that array_repr also
  1850. returns information on the kind of array and its data type.
  1851. Note:
  1852. Numpy argument `max_line_width`, `precision` and `suppress_small` are not supported.
  1853. Graph mode does not support the function.
  1854. Args:
  1855. a (Tensor): Input data.
  1856. Returns:
  1857. String.
  1858. Supported Platforms:
  1859. ``Ascend`` ``GPU`` ``CPU``
  1860. Raises:
  1861. TypeError: If input is not tensor.
  1862. Examples:
  1863. >>> import mindspore.numpy as np
  1864. >>> x = np.arange(5)
  1865. >>> np.array_str(x)
  1866. '[0 1 2 3 4]'
  1867. """
  1868. if not isinstance(a, Tensor):
  1869. _raise_type_error("Expect input to be tensor.")
  1870. return a.__str__()
  1871. def apply_along_axis(func1d, axis, arr, *args, **kwargs):
  1872. """
  1873. Applies a function to 1-D slices along the given axis.
  1874. Executes ``func1d(a, *args, **kwargs)`` where `func1d` operates on 1-D arrays and `a` is a
  1875. 1-D slice of arr along axis.
  1876. Args:
  1877. func1d (function): Maps `(M,) -> (Nj…)`. This function should accept 1-D arrays. It is
  1878. applied to 1-D slices of arr along the specified axis.
  1879. axis (int): Axis along which arr is sliced.
  1880. arr (Tensor): Input array with shape `(Ni…, M, Nk…)`.
  1881. args (any): Additional arguments to `func1d`.
  1882. kwargs (any): Additional named arguments to `func1d`.
  1883. Returns:
  1884. Tensor with shape `(Ni…, Nj…, Nk…)`, the output array. Its shape is identical to the
  1885. shape of `arr`, except along the `axis` dimension. This axis is removed, and replaced
  1886. with new dimensions equal to the shape of the return value of `func1d`. So if `func1d`
  1887. returns a scalar, the output will have one fewer dimensions than `arr`.
  1888. Supported Platforms:
  1889. ``Ascend`` ``GPU`` ``CPU``
  1890. Raises:
  1891. ValueError: if axis is out of the range.
  1892. Examples:
  1893. >>> import mindspore.numpy as np
  1894. >>> b = np.array([[1,2,3], [4,5,6], [7,8,9]])
  1895. >>> print(np.apply_along_axis(np.diag, -1, b))
  1896. [[[1 0 0]
  1897. [0 2 0]
  1898. [0 0 3]]
  1899. [[4 0 0]
  1900. [0 5 0]
  1901. [0 0 6]]
  1902. [[7 0 0]
  1903. [0 8 0]
  1904. [0 0 9]]]
  1905. """
  1906. ndim = F.rank(arr)
  1907. shape = F.shape(arr)
  1908. axis = _check_axis_in_range(axis, ndim)
  1909. arr = moveaxis(arr, axis, -1)
  1910. arr = F.reshape(arr, (-1, F.shape(arr)[-1]))
  1911. slices = []
  1912. for i in range(F.shape(arr)[0]):
  1913. slices.append(func1d(arr[i], *args, **kwargs))
  1914. stacked_slices = stack(slices)
  1915. shape_stacked = (_tuple_slice(shape, None, axis) + _tuple_slice(shape, axis + 1, None) +
  1916. _tuple_slice(F.shape(stacked_slices), 1, None))
  1917. res = F.reshape(stacked_slices, shape_stacked)
  1918. # moves the dimensions returned by `func1d` back to `axis`
  1919. ndim_func = F.rank(res) - ndim + 1
  1920. if ndim_func >= 1:
  1921. res = moveaxis(res, F.make_range(ndim - 1, F.rank(res)),
  1922. F.make_range(axis, axis + ndim_func))
  1923. return res
  1924. def _stack_arrays(arrs):
  1925. """Stacks a sequence of Tensor"""
  1926. if isinstance(arrs, (tuple, list)):
  1927. tensor_list = []
  1928. for arr in arrs:
  1929. tensor_list.append(_to_tensor(arr))
  1930. return stack(tensor_list)
  1931. return atleast_1d(_to_tensor(arrs))
  1932. def piecewise(x, condlist, funclist, *args, **kw):
  1933. """
  1934. Evaluates a piecewise-defined function.
  1935. Given a set of conditions and corresponding functions, evaluate each function on the input
  1936. data wherever its condition is true.
  1937. Args:
  1938. x (Union[int, float, bool, list, tuple, Tensor]): The input domain.
  1939. condlist (Union[bool, list of bool Tensor]): Each boolean array corresponds to a
  1940. function in `funclist`. Wherever `condlist[i]` is True, `funclist[i](x)` is used as
  1941. the output value. Each boolean array in `condlist` selects a piece of `x`, and
  1942. should therefore be of the same shape as `x`. The length of `condlist` must
  1943. correspond to that of `funclist`. If one extra function is given, i.e. if
  1944. ``len(funclist) == len(condlist) + 1``, then that extra function is the default
  1945. value, used wherever all conditions are false.
  1946. funclist (Union[list of callables, list of scalars]): Each function is evaluated over
  1947. `x` wherever its corresponding condition is True. It should take a 1d array as input
  1948. and give an 1d array or a scalar value as output. If, instead of a callable, a scalar
  1949. is provided then a constant function ``(lambda x: scalar)`` is assumed.
  1950. args (any): Any further arguments given to `piecewise` are passed to the functions upon
  1951. execution, i.e., if called ``piecewise(..., ..., 1, 'a')``, then each function is
  1952. called as ``f(x, 1, 'a')``.
  1953. kw (any): Keyword arguments used in calling `piecewise` are passed to the functions upon
  1954. execution, i.e., if called ``piecewise(..., ..., alpha=1)``, then each function is
  1955. called as ``f(x, alpha=1)``.
  1956. Returns:
  1957. Tensor, the output is the same shape and type as `x` and is found by calling the
  1958. functions in `funclist` on the appropriate portions of `x`, as defined by the boolean
  1959. arrays in `condlist`. Portions not covered by any condition have a default value of 0.
  1960. Supported Platforms:
  1961. ``Ascend`` ``GPU`` ``CPU``
  1962. Raises:
  1963. ValueError: if length of `funclist` is not in ``(len(condlist), len(condlist) + 1)``
  1964. Examples:
  1965. >>> import mindspore.numpy as np
  1966. >>> x = np.linspace(-2.5, 2.5, 6)
  1967. >>> print(np.piecewise(x, [x < 0, x >= 0], [-1, 1]))
  1968. [-1 -1 -1 1 1 1]
  1969. """
  1970. x = _to_tensor(x)
  1971. choicelist = funclist
  1972. if isinstance(funclist, (tuple, list)):
  1973. if _callable(x, funclist[0]):
  1974. choicelist = []
  1975. for func in funclist:
  1976. choicelist.append(func(x, *args, **kw))
  1977. condlist = _stack_arrays(condlist)
  1978. choicelist = _stack_arrays(choicelist)
  1979. default = 0
  1980. n1 = len(condlist)
  1981. n2 = len(funclist)
  1982. if n1 + 1 == n2:
  1983. default = choicelist[-1]
  1984. choicelist = choicelist[:-1]
  1985. elif n1 != n2:
  1986. _raise_value_error('the number of choices should be either equal to conditions or ', n1 + 1)
  1987. return select(condlist, choicelist, default=default)
  1988. def unravel_index(indices, shape, order='C'):
  1989. """
  1990. Converts a flat index or array of flat indices into a tuple of coordinate arrays.
  1991. Note:
  1992. Out-of-bound indices are clipped by the boundaries of `shape` instead of raising
  1993. an error.
  1994. Args:
  1995. indices (Union[int, float, bool, list, tuple, Tensor]): An integer array whose elements
  1996. are indices into the flattened version of an array of dimensions shape.
  1997. shape (tuple of integers): The shape of the array to use for unraveling indices.
  1998. order (Union['C', 'F'], optional): Determines whether the indices should be viewed as
  1999. indexing in row-major (C-style) or column-major (Fortran-style) order.
  2000. Returns:
  2001. Tensor, each array in the tuple has the same shape as the indices array.
  2002. Supported Platforms:
  2003. ``Ascend`` ``GPU`` ``CPU``
  2004. Raises:
  2005. ValueError: if `order` is not 'C' or 'F'.
  2006. Examples:
  2007. >>> import mindspore.numpy as np
  2008. >>> print(np.unravel_index([22, 41, 37], (7,6)))
  2009. (Tensor(shape=[3], dtype=Int32, value= [3, 6, 6]),
  2010. Tensor(shape=[3], dtype=Int32, value= [4, 5, 1]))
  2011. >>> print(np.unravel_index([31, 41, 13], (7,6), order='F'))
  2012. (Tensor(shape=[3], dtype=Int32, value= [3, 6, 6]),
  2013. Tensor(shape=[3], dtype=Int32, value= [4, 5, 1]))
  2014. """
  2015. indices = _to_tensor(indices)
  2016. if order not in ('C', 'F'):
  2017. _raise_value_error('invalid order. Expected "C" or "F"')
  2018. if isinstance(shape, int):
  2019. shape = (shape,)
  2020. ndim = F.rank(indices)
  2021. if order == 'F':
  2022. sizes = _cumprod(shape)
  2023. else:
  2024. sizes = _cumprod(shape[::-1])
  2025. sizes = _to_tensor(sizes[::-1] + (1,))
  2026. sizes = F.reshape(sizes, (-1,) + _list_comprehensions(ndim, 1, True))
  2027. total_size = sizes[0]
  2028. indices = where(indices > total_size - 1, total_size - 1, indices)
  2029. if _get_device() == 'GPU':
  2030. dtype = F.dtype(total_size)
  2031. lowerbounds = (-(total_size.astype(mstype.float32))).astype(dtype)
  2032. else:
  2033. lowerbounds = -total_size
  2034. indices = where(indices < lowerbounds, lowerbounds, indices)
  2035. res = _mod(indices, sizes[:-1])//sizes[1:]
  2036. num = len(res)
  2037. if ndim == 0 and num == 1:
  2038. return res.ravel()
  2039. if order == 'F':
  2040. r = range(num - 1, -1, -1)
  2041. else:
  2042. r = range(num)
  2043. subs = ()
  2044. for i in r:
  2045. subs += (res[i],)
  2046. return subs
  2047. def apply_over_axes(func, a, axes):
  2048. """
  2049. Applies a function repeatedly over multiple axes.
  2050. `func` is called as `res = func(a, axis)`, where `axis` is the first element of `axes`.
  2051. The result `res` of the function call must have either the same dimensions as `a` or
  2052. one less dimension. If `res` has one less dimension than `a`, a dimension is inserted before `axis`.
  2053. The call to `func` is then repeated for each axis in `axes`, with `res` as the first argument.
  2054. Args:
  2055. func (function): This function must take two arguments, `func(a, axis)`.
  2056. a (Union[int, float, bool, list, tuple, Tensor]): Input tensor.
  2057. axes (Union[int, list, tuple]): Axes over which `func` is applied; the elements must be integers.
  2058. Returns:
  2059. Tensor. The number of dimensions is the same as `a`, but the shape can be different.
  2060. This depends on whether `func` changes the shape of its output with respect to its input.
  2061. Raises:
  2062. TypeError: If input `a` is not array_like or `axes` is not int or sequence of ints.
  2063. ValueError: If any axis is out of range or duplicate axes exist.
  2064. Supported Platforms:
  2065. ``Ascend`` ``GPU`` ``CPU``
  2066. Examples:
  2067. >>> import mindspore.numpy as np
  2068. >>> x = np.arange(10).reshape(2, 5).astype('float32')
  2069. >>> print(x)
  2070. [[0. 1. 2. 3. 4.]
  2071. [5. 6. 7. 8. 9.]]
  2072. >>> print(np.apply_over_axes(np.sum, x, axes=0))
  2073. [[ 5. 7. 9. 11. 13.]]
  2074. """
  2075. a = _to_tensor(a)
  2076. if isinstance(axes, int):
  2077. axes = (axes,)
  2078. res = a
  2079. for axis in axes:
  2080. res = func(res, axis=axis)
  2081. res = F.expand_dims(res, axis) if res.ndim != a.ndim else res
  2082. if res.ndim != a.ndim:
  2083. _raise_value_error("function is not returning a tensor of the correct shape")
  2084. return res