mindspore.ops.primitive
operators that can be used for constructor function of Cell
For more information about dynamic shape support status, please refer to Dynamic Shape Support Status of primitive Interface .
For more information about the support for the bfloat16 data type, please refer to Support List .
For the details about the usage constraints of each operator in the operator parallel process, refer to Usage Constraints During Operator Parallel .
The module import method is as follows:
import mindspore.ops as ops
Compared with the previous version, the added, deleted and supported platforms change information of mindspore.ops.primitive operators in MindSpore, please refer to the link mindspore.ops.primitive API Interface Change .
Operator Primitives
Primitive is the base class of operator primitives in python. |
|
PrimitiveWithCheck is the base class of primitives in python, which defines functions to check the input arguments of operators, but uses the infer method registered in c++ source codes. |
|
PrimitiveWithInfer is the base class of primitives in python and defines functions for tracking inference in python. |
Neural Network Layer Operators
Neural Network
API Name |
Description |
Supported Platforms |
Warning |
Average pooling operation. |
|
None |
|
3D Average pooling operation. |
|
"kernel_size" is in the range [1, 255]. "strides" is in the range [1, 63]. |
|
Batch Normalization for input data and updated parameters. |
|
If the operation is used for inference, and outputs "reserve_space_1" and "reserve_space_2" are available, then "reserve_space_1" has the same value as "mean" and "reserve_space_2" has the same value as "variance". For Ascend 310, the result accuracy fails to reach 1‰ due to the square root instruction. |
|
2D convolution layer. |
|
None |
|
Calculates a 2D transposed convolution, which can be regarded as Conv2d for the gradient of the input, also called deconvolution, although it is not an actual deconvolution. |
|
None |
|
3D convolution layer. |
|
None |
|
Computes a 3D transposed convolution, which is also known as a deconvolution (although it is not an actual deconvolution). |
|
None |
|
Performs greedy decoding on the logits given in inputs. |
|
None |
|
The dense connected fusion operator. |
|
None |
|
During training, randomly zeroes some of the elements of the input tensor with probability \(1 - keep\_prob\) from a Bernoulli distribution. |
|
None |
|
During training, randomly zeroes some channels of the input tensor with probability \(1-keep\_prob\) from a Bernoulli distribution(For a 4-dimensional tensor with a shape of \((N, C, H, W)\), the channel feature map refers to a 2-dimensional feature map with the shape of \((H, W)\)). |
|
None |
|
During training, randomly zeroes some channels of the input tensor with probability \(1-keep\_prob\) from a Bernoulli distribution(For a 5-dimensional tensor with a shape of NCDHW, the channel feature map refers to a 3-dimensional feature map with a shape of DHW). |
|
None |
|
Applies a single-layer gated recurrent unit (GRU) to an input sequence. |
|
None |
|
Applies a recurrent neural network to the input. |
|
None |
|
Flattens a tensor without changing its batch size on the 0-th axis. |
|
None |
|
Applies a 3D fractional max pooling to an input signal composed of multiple input planes. |
|
This is an experimental API that is subject to change or deletion. |
|
This operation samples 2d input_x by using interpolation based on flow field grid, which is usually gennerated by |
|
This is an experimental API that is subject to change or deletion. |
|
Given an input and a grid, the output is calculated using the input values and pixel positions in the grid. |
|
This is an experimental API that is subject to change or deletion. |
|
Applies the Layer Normalization to the input tensor. |
|
None |
|
Local Response Normalization. |
|
LRN is deprecated on Ascend due to potential accuracy problem. It's recommended to use other normalization methods, e.g. |
|
Performs the Long Short-Term Memory (LSTM) on the input. |
|
None |
|
Max pooling operation. |
|
None |
|
Applies a 3D max pooling over an input Tensor which can be regarded as a composition of 3D planes. |
|
None |
|
Performs a 3D max pooling on the input Tensor and returns both max values and indices. |
|
This is an experimental API that is subject to change or deletion. |
|
Please use |
Deprecated |
None |
|
Performs max pooling on the input Tensor and returns both max values and indices. |
|
This is an experimental API that is subject to change or deletion. |
|
Calculates the partial inverse of MaxPool2D operation. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes the inverse of |
|
This is an experimental API that is subject to change or deletion. |
|
Pads the input tensor according to the paddings and mode. |
|
None |
|
Pads the input tensor according to the paddings. |
|
None |
|
Returns a slice of input tensor based on the specified indices. |
|
None |
|
Extends the last dimension of the input tensor from 1 to pad_dim_size, by filling with 0. |
|
None |
|
Resize images to size using bicubic interpolation. |
|
This is an experimental API that is subject to change or deletion. |
|
Resizes the input tensor to a given size by using the nearest neighbor algorithm. |
|
None |
Loss Function
API Name |
Description |
Supported Platforms |
Warning |
Adds sigmoid activation function to input logits, and uses the given logits to compute binary cross entropy between the logits and the label. |
|
None |
|
Computes the binary cross entropy between the logits and the labels. |
|
The value of \(x\) must range from 0 to 1. |
|
Calculates the CTC (Connectionist Temporal Classification) loss and the gradient. |
|
None |
|
Calculates the CTC (Connectionist Temporal Classification) loss and the gradient. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes the Kullback-Leibler divergence between the logits and the labels. |
|
None |
|
Calculates half of the L2 norm, but do not square the result. |
|
None |
|
Creates a loss criterion that minimizes the hinge loss for multi-class classification tasks. |
|
None |
|
Creates a loss function that minimizes the hinge loss for multi-class classification tasks. |
|
This is an experimental API that is subject to change or deletion. |
|
Gets the negative log likelihood loss between logits and labels. |
|
None |
|
Computes the RNNTLoss and its gradient with respect to the softmax outputs. |
|
None |
|
Uses the given logits to compute sigmoid cross entropy between the logits and the label. |
|
None |
|
Calculate the smooth L1 loss, and the L1 loss function has robustness. |
|
None |
|
SoftMarginLoss operation. |
|
None |
|
Gets the softmax cross-entropy value between logits and labels with one-hot encoding. |
|
None |
|
Computes the softmax cross-entropy value between logits and sparse encoding labels. |
|
None |
|
TripletMarginLoss operation. |
|
None |
Activation Function
API Name |
Description |
Supported Platforms |
Warning |
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Gaussian Error Linear Units activation function. |
|
None |
|
Computes GLU (Gated Linear Unit activation function) of input tensors. |
|
This is an experimental API that is subject to change or deletion. |
|
Hard Shrink activation function. |
|
None |
|
Hard sigmoid activation function. |
|
None |
|
Hard swish activation function. |
|
None |
|
Refer to |
|
None |
|
Computes MISH(A Self Regularized Non-Monotonic Neural Activation Function) of input tensors element-wise. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Activation function SeLU (Scaled exponential Linear Unit). |
|
None |
|
Refer to |
|
None |
|
Applies the Softmax operation to the input tensor on the specified axis. |
|
None |
|
Softplus activation function. |
|
None |
|
Applies the SoftShrink function element-wise. |
|
None |
|
Softsign activation function. |
|
None |
|
Computes hyperbolic tangent of input element-wise. |
|
None |
Optimizer
API Name |
Description |
Supported Platforms |
Warning |
Updates gradients by the Adaptive Moment Estimation (Adam) algorithm. |
|
None |
|
Updates gradients by the Adaptive Moment Estimation algorithm with weight decay (AdamWeightDecay). |
|
None |
|
AdaptiveAvgPool2D operation. |
|
This is an experimental API that is subject to change or deletion. |
|
AdaptiveAvgPool3D operation. |
|
This is an experimental API that is subject to change or deletion. |
|
Updates relevant entries according to the adadelta scheme. |
|
None |
|
Updates relevant entries according to the adagrad scheme. |
|
None |
|
Update var according to the proximal adagrad scheme. |
|
None |
|
Updates relevant entries according to the adagradv2 scheme. |
|
None |
|
Updates relevant entries according to the adamax scheme. |
|
None |
|
Update var according to the Adam algorithm. |
|
None |
|
Updates relevant entries according to the AddSign algorithm. |
|
None |
|
Optimizer that implements the centered RMSProp algorithm. |
|
In dense implementation of this algorithm, mean_gradient, mean_square, and moment will update even if the grad is zero. But in this sparse implementation, mean_gradient, mean_square, and moment will not update in iterations during which the grad is zero. |
|
Updates relevant entries according to the FTRL scheme. |
|
None |
|
Updates var by subtracting alpha * delta from it. |
|
None |
|
Optimizer that implements the Momentum algorithm. |
|
None |
|
Updates relevant entries according to the AddSign algorithm. |
|
None |
|
Updates relevant entries according to the proximal adagrad algorithm. |
|
None |
|
Updates relevant entries according to the FOBOS(Forward Backward Splitting) algorithm. |
|
None |
|
Optimizer that implements the Root Mean Square prop(RMSProp) algorithm. |
|
Note that in dense implementation of this algorithm, "mean_square" and "moment" will update even if "grad" is 0, but in this sparse implementation, "mean_square" and "moment" will not update in iterations during which "grad" is 0. |
|
Conducts LARS (layer-wise adaptive rate scaling) update on the sum of squares of gradient. |
|
None |
|
Updates relevant entries according to the adagrad scheme, one more epsilon attribute than SparseApplyAdagrad. |
|
None |
|
Updates relevant entries according to the proximal adagrad algorithm. |
|
None |
|
Computes the stochastic gradient descent. |
|
None |
|
Updates relevant entries according to the FTRL-proximal scheme For more details, please refer to |
|
None |
|
The SparseApplyFtrlV2 interface is deprecated, please use the |
Deprecated |
None |
Distance Function
API Name |
Description |
Supported Platforms |
Warning |
Computes batched the p-norm distance between each pair of the two collections of row vectors. |
|
None |
|
Computes the Levenshtein Edit Distance. |
|
Unorded truth_indices or hypothesis_indices might lead to expected result, so it is suggested to make sure truth_indices and hypothesis_indices are both in ascending order before calling this API. |
|
Return the p-norm of a matrix or vector. |
|
None |
|
Computes the p-norm distance between each pair of row vectors in the input. |
|
None |
Sampling Operator
API Name |
Description |
Supported Platforms |
Warning |
Compute accidental hits of sampled classes which match target classes. |
|
None |
|
Generates random labels with a log-uniform distribution for sampled_candidates. |
|
None |
|
Uniform candidate sampler. |
|
None |
Image Processing
API Name |
Description |
Supported Platforms |
Warning |
Decodes bounding boxes locations. |
|
None |
|
Encodes bounding boxes locations. |
|
None |
|
Checks bounding box. |
|
None |
|
Extracts crops from the input image tensor and resizes them. |
|
None |
|
ops.ExtractVolumePatches is deprecated from version 2.3 and will be removed in a future version. |
Deprecated |
None |
|
Calculates intersection over union for boxes. |
|
None |
|
L2 Normalization Operator. |
|
None |
|
Non-maximum Suppression. |
|
Only supports up to 2864 input boxes at one time. |
|
Resizes an image to a certain size using the bilinear interpolation. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes the Region of Interest (RoI) Align operator. |
|
None |
|
Performs nearest neighbor upsampling operation. |
|
None |
|
Performs upsampling with trilinear interpolation across 3dims for 5dim input Tensor. |
|
None |
Text Processing
API Name |
Description |
Supported Platforms |
Warning |
Updates the probability of occurrence of words with its corresponding n-grams. |
|
None |
Feature Value Detection
API Name |
Description |
Supported Platforms |
Warning |
ASDBase is the base class of operator with feature value detection feature in python. |
|
None |
Mathematical Operators
API Name |
Description |
Supported Platforms |
Warning |
Counts the number of occurrences of each value in an integer array. |
|
This is an experimental API that is subject to change or deletion. |
|
Performs the Cholesky decomposition on a single or a batch of symmetric positive-definite matrices. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns a complex Tensor from the real part and the imag part. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns a Tensor that contains the magnitudes of the input. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns the cross product of vectors in dimension dim of x1 and x2. |
|
This is an experimental API that is subject to change or deletion. |
|
Fourier transform, can be adjusted by parameters to achieve FFT/IFFT/RFFT/IRFFT. |
|
This is an experimental API that is subject to change or deletion. |
|
Refer to |
|
None |
Element-wise Operator
API Name |
Description |
Supported Platforms |
Warning |
Refer to |
|
None |
|
Computes accumulation of all input tensors element-wise. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Adds the element-wise division of x1 by x2, multiplied by value to input_data. |
|
None |
|
Adds the element-wise product of x1 by x2, multiplied by value to input_data. |
|
None |
|
Computes addition of all input tensors element-wise. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Computes modified Bessel function of the first kind, order 0 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes exponential scaled modified Bessel function of the first kind, order 0 element-wise. |
|
None |
|
Computes modified Bessel function of the first kind, order 1 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes exponential scaled modified Bessel function of the first kind, order 1 element-wise. |
|
None |
|
Computes Bessel function of the first kind, order 0 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes Bessel function of the first kind, order 1 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes modified Bessel function of the second kind, order 0 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes exponential scaled modified Bessel function of the second kind, order 0 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes modified Bessel function of the second kind, order 1 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes exponential scaled modified Bessel function of the second kind, order 1 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes Bessel function of the second kind, order 0 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes Bessel function of the second kind, order 1 element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns bitwise and of two tensors element-wise. |
|
None |
|
Returns bitwise or of two tensors element-wise. |
|
None |
|
Returns bitwise xor of two tensors element-wise. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Computes the grad of the lgamma function on input. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes the quotient of dividing the first input tensor by the second input tensor element-wise. |
|
None |
|
Operates a safe division between x1 and x2 element-wise. |
|
None |
|
Sums the product of the elements of the input Tensor along dimensions specified notation based on the Einstein summation convention(Einsum). |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Returns a new tensor containing imaginary value of the input. |
|
None |
|
Computes Reciprocal of input tensor element-wise. |
|
None |
|
Flips all bits of input tensor element-wise. |
|
None |
|
Does a linear interpolation of two tensors start and end based on a float or tensor weight. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Computes the "logical AND" of two tensors element-wise. |
|
None |
|
Computes the "logical NOT" of a tensor element-wise. |
|
None |
|
Computes the "logical OR" of two tensors element-wise. |
|
None |
|
Computes the "logical XOR" of two tensors element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Calculate the logit of a tensor element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes the remainder of dividing the first input tensor by the second input tensor element-wise. |
|
The input data does not support 0. When the elements of input exceed 2048, the accuracy of operator cannot guarantee the requirement of double thousandths in the mini form. Due to different architectures, the calculation results of this operator on NPU and CPU may be inconsistent. If shape is expressed as \((D1, D2, ..., Dn)\), then \(D1*D2... *DN<=1000000,n<=8\). |
|
Refer to |
|
None |
|
Computes x * y element-wise. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Converts polar coordinates to Cartesian coordinates. |
|
None |
|
Computes the \(a\). |
|
This is an experimental API that is subject to change or deletion. |
|
Refer to |
|
None |
|
Divides the first input tensor by the second input tensor in floating-point type element-wise. |
|
None |
|
Returns reciprocal of a tensor element-wise. |
|
None |
|
Returns an integer that is closest to input_x element-wise. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Performs sign on the tensor element-wise. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Subtracts the second input tensor from the first input tensor element-wise and returns square of it. |
|
None |
|
Returns the square sum of a tensor element-wise. |
|
None |
|
Subtracts the second input tensor from the first input tensor element-wise. |
|
None |
|
Computes tangent of x element-wise. |
|
None |
|
Returns a new tensor with the truncated integer values of the elements of input. |
|
None |
|
Divides the first input tensor by the second input tensor element-wise and rounds the results of division towards zero. |
|
None |
|
Returns the remainder of division element-wise. |
|
The input data does not support 0. When the elements of input exceed 2048, the accuracy of operator cannot guarantee the requirement of double thousandths in the mini form. Due to different architectures, the calculation results of this operator on NPU and CPU may be inconsistent. If shape is expressed as (D1,D2... ,Dn), then D1*D2... *DN<=1000000,n<=8. |
|
Divides the first input tensor by the second input tensor element-wise. |
|
None |
|
Computes the first input tensor multiplied by the logarithm of second input tensor element-wise. |
|
None |
|
Compute the Hurwitz zeta function ζ(x,q) of input Tensor. |
|
This is an experimental API that is subject to change or deletion. |
Reduction Operator
API Name |
Description |
Supported Platforms |
Warning |
Returns the indices of the maximum value along a specified axis of a Tensor. |
|
None |
|
Calculates the maximum value along with the given axis for the input tensor, and returns the maximum values and indices. |
|
If there are multiple maximum values, the index of the first maximum value is used. The value range of axis is [-dims, dims - 1]. "dims" is the dimension length of input. |
|
Returns the indices of the minimum value along a specified axis of a Tensor. |
|
None |
|
Calculates the minimum value along with the given axis for the input tensor, and returns the minimum values and indices. |
|
If there are multiple minimum values, the index of the first minimum value is used. The value range of axis is [-dims, dims - 1]. "dims" is the dimension length of input. |
|
Computes the median and its corresponding indices of input tensor in the axis dimension. |
|
indices does not necessarily contain the first occurrence of each median value found in the input, unless it is unique. The specific implementation of this API is device-specific. The results may be different on CPU and GPU. When attr global_median is |
|
Reduces a dimension of a tensor by the "logicalAND" of all elements in the dimension, by default. |
|
None |
|
Reduces a dimension of a tensor by the "logical OR" of all elements in the dimension, by default. |
|
None |
|
Reduces a dimension of a tensor by the maximum value in this dimension, by default. |
|
None |
|
Reduces a dimension of a tensor by averaging all elements in the dimension, by default. |
|
None |
|
Reduces a dimension of a tensor by the minimum value in the dimension, by default. |
|
None |
|
Reduces a dimension of a tensor by multiplying all elements in the dimension, by default. |
|
None |
|
Reduces a dimension of a tensor by summing all elements in the dimension, by default. |
|
None |
Comparison Operator
API Name |
Description |
Supported Platforms |
Warning |
Returns |
|
None |
|
Refer to |
|
None |
|
Computes the number of the same elements of two tensors. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Determines whether the targets are in the top k predictions. |
|
None |
|
Determines which elements are finite for each position. |
|
None |
|
Determines which elements are inf or -inf for each position. |
|
None |
|
Determines which elements are NaN for each position. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Finds values and indices of the k largest entries along the last dimension. |
|
If sorted is set to False, it will use the aicpu operator, the performance may be reduced. In addition, due to different memory layout and traversal methods on different platforms, the display order of calculation results may be inconsistent when sorted is False. |
Linear Algebraic Operator
API Name |
Description |
Supported Platforms |
Warning |
Computes matrix multiplication between two tensors by batch. |
|
None |
|
Returns the sum of the input Tensor and the bias Tensor. |
|
None |
|
Ger product of x1 and x2. |
|
None |
|
Multiplies matrix a and matrix b. |
|
None |
|
Returns the inverse of the input matrix. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes the matrix-matrix multiplication of a product of Householder matrices with a general matrix. |
|
This is an experimental API that is subject to change or deletion. |
|
Calculates the explicit representation of the orthogonal matrix \(Q\) returned by |
|
This is an experimental API that is subject to change or deletion. |
|
Computes the singular value decompositions of one or more matrices. |
|
None |
Tensor Operation Operator
Tensor Construction
API Name |
Description |
Supported Platforms |
Warning |
Create a Tensor with the same data type and shape as input, and the element value is the minimum value that the corresponding data type can express. |
|
None |
|
Creates a tensor with ones on the diagonal and zeros in the rest. |
|
None |
|
The Fill interface is deprecated, please use the |
Deprecated |
None |
|
Returns a Tensor whose value is num evenly spaced in the interval start and stop (including start and stop), and the length of the output Tensor is num. |
|
None |
|
Computes a one-hot tensor. |
|
None |
|
Creates a tensor filled with value ones. |
|
None |
|
Returns a Tensor with a value of 1 and its shape and data type is the same as the input. |
|
None |
|
Zeros will be deprecated in the future. |
Deprecated |
None |
|
Returns a Tensor with a value of 0 and its shape and data type is the same as the input. |
|
None |
Random Generation Operator
API Name |
Description |
Supported Platforms |
Warning |
Randomly set the elements of output to 0 or 1 with the probability of P which follows the Bernoulli distribution. |
|
This is an experimental API that is subject to change or deletion. |
|
Produces random positive floating-point values x, distributed according to probability density function: |
|
None |
|
Returns a tensor sampled from the multinomial probability distribution located in the corresponding row of tensor input. |
|
None |
|
Returns a tensor where each row contains numsamples indices sampled from the multinomial distribution with replacement. |
|
This is an experimental API that is subject to change or deletion. |
|
Generates random samples from a given categorical distribution tensor. |
|
None |
|
Generates a random sample as index tensor with a mask tensor from a given tensor. |
|
None |
|
Produces random positive floating-point values x, distributed according to probability density function: |
|
None |
|
Produces random non-negative values i, distributed according to discrete probability function: |
|
None |
|
Generates n random samples from 0 to n-1 without repeating. |
|
None |
|
Refer to |
|
None |
|
Generates random numbers according to the Laplace random number distribution (mean=0, lambda=1). |
|
None |
|
Generates random numbers according to the standard Normal (or Gaussian) random number distribution. |
|
None |
|
Produces random integer values i, uniformly distributed on the closed interval [minval, maxval), that is, distributed according to the discrete probability function: |
|
None |
|
Produces random floating-point values, uniformly distributed to the interval [0, 1). |
|
None |
Array Operation
API Name |
Description |
Supported Platforms |
Warning |
Creates a 2D or 3D flow field (sampling grid) based on a batch of affine matrices theta. |
|
This is an experimental API that is subject to change or deletion. |
|
Divides batch dimension with blocks and interleaves these blocks back into spatial dimensions. |
|
None |
|
Please use batch_to_space_nd instead. |
Deprecated |
None |
|
Refer to |
|
None |
|
Returns a tensor with the new specified data type. |
|
None |
|
Divide the channels in a tensor of shape \((*, C, H, W)\) into \(g\) group and rearrange them as \((*, \frac C g, g, H*W)\), while keeping the original tensor shapes. |
|
This is an experimental API that is subject to change or deletion. |
|
Rearranges a row vector to an image. |
|
This is an experimental API that is subject to change or deletion. |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Returns the cumulative minimum of elements and the index. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes the cumulative product of the tensor x along axis. |
|
None |
|
Computes the cumulative sum of input tensor along axis. |
|
None |
|
Returns the dimension index in the destination data format given in the source data format. |
|
None |
|
Rearrange blocks of depth data into spatial dimensions. |
|
None |
|
Refer to |
|
None |
|
Returns the data type of the input tensor as mindspore.dtype. |
|
None |
|
Refer to |
|
None |
|
Fills the main diagonal of a Tensor in-place with a specified value and returns the result. |
|
This is an experimental API that is subject to change or deletion. |
|
Creates a tensor with shape described by shape and fills it with values in value . |
|
None |
|
Determines if the elements contain Not a Number(NaN), infinite or negative infinite. |
|
None |
|
Computes the maximum of input tensors element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Computes the hamming window function with input window length. |
|
This is an experimental API that is subject to change or deletion. |
|
Applies the Heaviside step function for input x element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns a rank 1 histogram counting the number of entries in values that fall into every bin. |
|
None |
|
Computes hypotenuse of input tensors element-wise as legs of a right triangle. |
|
This is an experimental API that is subject to change or deletion. |
|
Refer to |
|
None |
|
Calculates lower regularized incomplete Gamma function. |
|
This is an experimental API that is subject to change or deletion. |
|
Compute the upper regularized incomplete Gamma function Q(a, x). |
|
None |
|
Extracts sliding local blocks from a batched input tensor. |
|
This is an experimental API that is subject to change or deletion. |
|
Adds tensor y to specified axis and indices of tensor x. |
|
None |
|
Fills the elements under the dim dimension of the input Tensor x with the input value by selecting the indices in the order given in index. |
|
This is an experimental API that is subject to change or deletion. |
|
According to the index number of indexes, replace the value corresponding to x1 with the value in x2. |
|
None |
|
Adds v into specified rows of x. |
|
None |
|
Adds Tensor updates to specified axis and indices of Tensor var element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Subtracts v into specified rows of x. |
|
None |
|
Please use |
Deprecated |
None |
|
Updates specified values in x to v according to indices. |
|
This is an experimental API that is subject to change or deletion. |
|
Computes the inverse of an index permutation. |
|
None |
|
Returns a tensor of Boolean values indicating whether two input tensors are element-wise equal within a given tolerance. |
|
None |
|
Computes least common multiplier of input tensors element-wise. |
|
This is an experimental API that is subject to change or deletion. |
|
Shift the value of each position of the tensor to the left several bits. |
|
This is an experimental API that is subject to change or deletion. |
|
Generates a 1-D Tensor with a length of steps. |
|
This is an experimental API that is subject to change or deletion. |
|
Converts LU_data and LU_pivots back into P, L and U matrices, where P is a permutation matrix, L is a lower triangular matrix, and U is an upper triangular matrix. |
|
This is an experimental API that is subject to change or deletion. |
|
Refer to |
|
None |
|
Updates the value in the input with value in updates according to the mask. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns a new 1-D Tensor which indexes the x tensor according to the boolean mask. |
|
None |
|
Extracts the central diagonal band of each matrix in a tensor, with all values outside the central band set to zero. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns the diagonal part of a tensor. |
|
This is an experimental API that is subject to change or deletion. |
|
Constructs a diagonal matrix or a batch of diagonal matrices from a given input Tensor. |
|
This is an experimental API that is subject to change or deletion. |
|
Updates the diagonal part of a batched tensor. |
|
This is an experimental API that is subject to change or deletion. |
|
Solves systems of linear equations. |
|
None |
|
Generates coordinate matrices from given coordinate tensors. |
|
None |
|
Calculates the multivariate log-gamma function element-wise for a given dimension p. |
|
This is an experimental API that is subject to change or deletion. |
|
Replaces NaN, positive infinity and negative infinity values in the input Tensor with the values specified by nan, posinf and neginf respectively. |
|
This is an experimental API that is subject to change or deletion. |
|
Refer to |
|
None |
|
Concats input tensors along the first dimension. |
|
None |
|
Computes element-wise population count(a.k.a bitsum, bitcount). |
|
None |
|
Randomly shuffles a Tensor along its first dimension. |
|
None |
|
Refer to |
|
None |
|
Returns the rank of a tensor. |
|
None |
|
Renormalizes the sub-tensors along dimension dim, and each sub-tensor's p-norm should not exceed the 'maxnorm'. |
|
None |
|
Refer to |
|
None |
|
Reverses variable length slices. |
|
None |
|
Refer to |
|
None |
|
Shift the value of each position of Tensor input_x to the right by corresponding bits in Tensor input_y. |
|
This is an experimental API that is subject to change or deletion. |
|
Refer to |
|
None |
|
Applies sparse division to individual values or slices in a tensor. |
|
This is an experimental API that is subject to change or deletion. |
|
Applies sparse maximum to individual values or slices in a tensor. |
|
None |
|
Applies sparse minimum to individual values or slices in a tensor. |
|
None |
|
Applies sparse multiplication to individual values or slices in a tensor. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns the indices correspond to the positions where the given numbers in values should be inserted into sorted_sequence so that the order of the sequence is maintained. |
|
This is an experimental API that is subject to change or deletion. |
|
The conditional tensor determines whether the corresponding element in the output must be selected from x (if True) or y (if False) based on the value of each element. |
|
None |
|
Returns the shape of the input tensor. |
|
None |
|
Returns a Scalar of type int that represents the size of the input Tensor and the total number of elements in the Tensor. |
|
None |
|
Slices a tensor in the specified shape. |
|
None |
|
Sorts the elements of the input tensor along the given dimension in the specified order. |
|
Currently, the data types of float16, uint8, int8, int16, int32, int64 are well supported. If use float32, it may cause loss of accuracy. |
|
Divides spatial dimensions into blocks and combines the block size with the original batch. |
|
None |
|
Rearrange blocks of spatial data into depth. |
|
None |
|
Returns a slice of input tensor based on the specified indices and axis. |
|
None |
|
Splits the input tensor into output_num of tensors along the given axis and output numbers. |
|
None |
|
Return the Tensor after deleting the dimension of size 1 in the specified axis. |
|
None |
|
Stacks a list of tensors in specified axis. |
|
None |
|
Refer to |
|
None |
|
Creates a new tensor by adding the values from the positions in input_x indicated by indices, with values from updates. |
|
None |
|
Creates a new tensor by dividing the values from the positions in input_x indicated by indices, with values from updates. |
|
None |
|
By comparing the value at the position indicated by indices in x with the value in the updates, the value at the index will eventually be equal to the largest one to create a new tensor. |
|
None |
|
By comparing the value at the position indicated by indices in input_x with the value in the updates, the value at the index will eventually be equal to the smallest one to create a new tensor. |
|
None |
|
Creates a new tensor by multiplying the values from the positions in input_x indicated by indices, with values from updates. |
|
None |
|
Creates a new tensor by subtracting the values from the positions in input_x indicated by indices, with values from updates. |
|
None |
|
Creates a new tensor by updating the positions in input_x indicated by indices, with values from update. |
|
None |
|
Returns the shape of the input tensor. |
|
None |
|
Replicates an input tensor with given multiple times. |
|
None |
|
Refer to |
|
None |
|
Refer to |
|
None |
|
Returns the lower triangular portion of the 2-D matrix or the set of matrices in a batch. |
|
This is an experimental API that is subject to change or deletion. |
|
Calculates the indices of the lower triangular elements in a row * col matrix and returns them as a 2-by-N Tensor. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns the upper triangular portion of the 2-D matrix or the set of matrices in a batch. |
|
This is an experimental API that is subject to change or deletion. |
|
Calculates the indices of the upper triangular elements in a row * col matrix and returns them as a 2-by-N Tensor. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns the unique elements of input tensor and also return a tensor containing the index of each value of input tensor corresponding to the output unique tensor. |
|
None |
|
Returns the elements that are unique in each consecutive group of equivalent elements in the input tensor. |
|
This is an experimental API that is subject to change or deletion. |
|
Returns unique elements and relative indexes in 1-D tensor, filled with padding num. |
|
None |
|
Computes the maximum along segments of a tensor. |
|
None |
|
Computes the minimum of a tensor along segments. |
|
None |
|
Computes the product of a tensor along segments. |
|
None |
|
Refer to |
|
None |
|
Unstacks tensor in specified axis, this is the opposite of ops.Stack. |
|
None |
Type Conversion
API Name |
Description |
Supported Platforms |
Warning |
'ops.ScalarCast' is deprecated from version 2.3 and will be removed in a future version, please use int(x) or float(x) instead. |
Deprecated |
None |
|
Converts a scalar to a Tensor, and converts the data type to the specified type. |
|
None |
|
Converts a tuple to a tensor. |
|
None |
Parameter Operation Operator
API Name |
Description |
Supported Platforms |
Warning |
Refer to |
|
None |
|
Refer to |
|
None |
|
Updates a Parameter by subtracting a value from it. |
|
None |
|
Updates the value of the input tensor through the addition operation. |
|
None |
|
Updates the value of the input tensor through the divide operation. |
|
None |
|
Updates the value of the input tensor through the maximum operation. |
|
None |
|
Updates the value of the input tensor through the minimum operation. |
|
None |
|
Updates the value of the input tensor through the multiply operation. |
|
None |
|
Applies sparse addition to individual values or slices in a tensor. |
|
None |
|
Applies sparse subtraction to individual values or slices in a tensor. |
|
None |
|
Updates tensor values by using input indices and value. |
|
None |
|
Please use TensorScatterAdd instead. |
Deprecated |
None |
|
Updates the value of the input tensor through the subtraction operation. |
|
None |
|
Updates tensor values by using input indices and value. |
|
None |
Data Operation Operator
API Name |
Description |
Supported Platforms |
Warning |
Returns the next element in the dataset queue. |
|
None |
Communication Operator
Distributed training involves communication operations for data transfer. For more details, refer to Distributed Set Communication Primitives .
Note that the APIs in the following list need to preset communication environment variables. For the Ascend devices, users need to prepare the rank table, set rank_id and device_id. Please see the rank table Startup for more details. For the GPU device, users need to prepare the host file and mpi, please see the mpirun Startup . For the CPU device, users need to write a dynamic cluster startup script, please see the Dynamic Cluster Startup .
API Name |
Description |
Supported Platforms |
Warning |
Gathers tensors from the specified communication group. |
|
None |
|
Reduces the tensor data across all devices in such a way that all devices will get the same final result. |
|
None |
|
AlltoAll is a collective operation. |
|
None |
|
Broadcasts the tensor to the whole group. |
|
None |
|
NeighborExchangeV2 is a collective communication operation. |
|
None |
|
Operation options for reducing tensors. |
|
None |
|
Reduces and scatters tensors from the specified communication group. |
|
None |
Debugging Operator
API Name |
Description |
Supported Platforms |
Warning |
This operator will calculate the histogram of a tensor and put it to a summary file with protocol buffer format. |
|
None |
|
This operator will put an image tensor to a summary file with protocol buffer format. |
|
None |
|
This operator will put a scalar to a summary file with protocol buffer format. |
|
None |
|
This operator will put a tensor to a summary file with protocol buffer format. |
|
None |
|
Save the Tensor as an npy file in numpy format. |
|
If a large amount of data is stored within a short period, it may lead to memory overflow on the device side. Consider slicing the data to reduce the data scale. Since data saving is processed asynchronously, when the amount of data is too large or the main process exits too quickly, data loss may occur. You need to actively control the destruction time of the main process, such as using sleep. |
|
Print the inputs to stdout. |
|
None |
|
Allocates a flag to store the overflow status. |
|
None |
|
Clears the flag which stores the overflow status. |
|
None |
|
mindspore.ops.NPUGetFloatStatus updates the flag which is the output tensor of |
|
None |
Sparse Operator
API Name |
Description |
Supported Platforms |
Warning |
Multiplies sparse matrix A by dense matrix B. |
|
None |
|
Converts a sparse representation into a dense tensor. |
|
None |
Frame Operators
API Name |
Description |
Supported Platforms |
Warning |
Depend is used for processing dependency operations. |
|
None |
|
A higher-order function which is used to generate the gradient function for the input function. |
|
None |
|
This operation is used as a tag to hook gradient in intermediate variables. |
|
None |
|
Hypermap will apply the set operation to input sequences. |
|
None |
|
Attaches callback to the graph node that will be invoked on the node's gradient. |
|
None |
|
Map will apply the set operation on input sequences. |
|
None |
|
MultitypeFuncGraph is a class used to generate overloaded functions, considering different types as inputs. |
|
None |
|
Makes a partial function instance. |
|
None |
Operator Information Registration
Class for AiCPU operator information registration. |
|
Class used for generating the registration information for the func parameter of |
|
Various combinations of dtype and format of Ascend ops. |
|
Class for TBE operator information registration. |
|
Gets the virtual implementation function by a primitive object or primitive name. |
Customizing Operator
API Name |
Description |
Supported Platforms |
Warning |
Custom primitive is used for user defined operators and is to enhance the expressive ability of built-in primitives. |
|
This is an experimental API that is subject to change. |
|
A decorator which is used to bind the registration information to the func parameter of |
|
None |
|
The decorator of the Hybrid DSL function for the Custom Op. |
|
None |
Spectral Operator
API Name |
Description |
Supported Platforms |
Warning |
Bartlett window function. |
|
This is an experimental API that is subject to change or deletion. |
|
Blackman window function. |
|
This is an experimental API that is subject to change or deletion. |