mindspore.ops

Operators can be used in the construct function of Cell.

Examples

>>> import mindspore.ops as ops

Compared with the previous version, the added, deleted and supported platforms change information of mindspore.ops operators in MindSpore, please refer to the link https://gitee.com/mindspore/docs/blob/r1.3/resource/api_updates/ops_api_updates.md.

operations

The Primitive operators in operations need to be instantiated before being used.

Neural Network Operators

API Name

Description

Supported Platforms

mindspore.ops.Acosh

Computes inverse hyperbolic cosine of the inputs element-wise.

Ascend GPU CPU

mindspore.ops.Adam

Updates gradients by the Adaptive Moment Estimation (Adam) algorithm.

Ascend GPU CPU

mindspore.ops.AdamNoUpdateParam

Updates gradients by Adaptive Moment Estimation (Adam) algorithm.

CPU

mindspore.ops.AdaptiveAvgPool2D

AdaptiveAvgPool2D operation.

GPU

mindspore.ops.ApplyAdadelta

Updates relevant entries according to the adadelta scheme.

Ascend

mindspore.ops.ApplyAdagrad

Updates relevant entries according to the adagrad scheme.

Ascend CPU GPU

mindspore.ops.ApplyAdagradV2

Updates relevant entries according to the adagradv2 scheme.

Ascend

mindspore.ops.ApplyAdaMax

Updates relevant entries according to the adamax scheme.

Ascend

mindspore.ops.ApplyAddSign

Updates relevant entries according to the AddSign algorithm.

Ascend

mindspore.ops.ApplyCenteredRMSProp

Optimizer that implements the centered RMSProp algorithm.

Ascend GPU CPU

mindspore.ops.ApplyGradientDescent

Updates relevant entries according to the following.

Ascend GPU

mindspore.ops.ApplyMomentum

Optimizer that implements the Momentum algorithm.

Ascend GPU CPU

mindspore.ops.ApplyPowerSign

Updates relevant entries according to the AddSign algorithm.

Ascend

mindspore.ops.ApplyProximalAdagrad

Updates relevant entries according to the proximal adagrad algorithm.

Ascend

mindspore.ops.ApplyProximalGradientDescent

Updates relevant entries according to the FOBOS(Forward Backward Splitting) algorithm.

Ascend

mindspore.ops.ApplyRMSProp

Optimizer that implements the Root Mean Square prop(RMSProp) algorithm.

Ascend GPU CPU

mindspore.ops.AvgPool

Average pooling operation.

Ascend GPU CPU

mindspore.ops.AvgPool3D

3D Average pooling operation.

Ascend

mindspore.ops.BasicLSTMCell

It's similar to operator DynamicRNN.

Deprecated

mindspore.ops.BatchNorm

Batch Normalization for input data and updated parameters.

Ascend CPU GPU

mindspore.ops.BCEWithLogitsLoss

Adds sigmoid activation function to input predict, and uses the given logits to compute binary cross entropy between the target and the output.

Ascend GPU

mindspore.ops.BiasAdd

Returns sum of input and bias tensor.

Ascend GPU CPU

mindspore.ops.BinaryCrossEntropy

Computes the binary cross entropy between the target and the output.

Ascend GPU CPU

mindspore.ops.BNTrainingReduce

For the BatchNorm operation this operator updates the moving averages for training and is used in conjunction with BNTrainingUpdate.

Ascend

mindspore.ops.BNTrainingUpdate

For the BatchNorm operation, this operator updates the moving averages for training and is used in conjunction with BNTrainingReduce.

Ascend

mindspore.ops.ComputeAccidentalHits

Compute accidental hits of sampled classes which match target classes.

Ascend

mindspore.ops.Conv2D

2D convolution layer.

Ascend GPU CPU

mindspore.ops.Conv2DBackpropInput

Computes the gradients of convolution with respect to the input.

Ascend GPU CPU

mindspore.ops.Conv3D

3D convolution layer.

Ascend GPU

mindspore.ops.Conv3DTranspose

Computes a 3D transposed convolution, which is also known as a deconvolution (although it is not an actual deconvolution).

Ascend

mindspore.ops.CTCGreedyDecoder

Performs greedy decoding on the logits given in inputs.

Ascend

mindspore.ops.CTCLoss

Calculates the CTC (Connectionist Temporal Classification) loss and the gradient.

Ascend GPU CPU

mindspore.ops.DataFormatDimMap

Returns the dimension index in the destination data format given in the source data format.

Ascend

mindspore.ops.DepthwiseConv2dNative

Returns the depth-wise convolution value for the input.

Ascend

mindspore.ops.Dropout

During training, randomly zeroes some of the elements of the input tensor with probability.

Ascend GPU CPU

mindspore.ops.Dropout2D

During training, randomly zeroes some of the channels of the input tensor with probability 1-keep_prob from a Bernoulli distribution.

Ascend

mindspore.ops.Dropout3D

During training, randomly zeroes some of the channels of the input tensor with probability 1-keep_prob from a Bernoulli distribution.

Ascend GPU

mindspore.ops.DropoutDoMask

Applies dropout mask on the input tensor.

Ascend

mindspore.ops.DropoutGenMask

Generates the mask value for the input shape.

Ascend

mindspore.ops.DynamicGRUV2

Applies a single-layer gated recurrent unit (GRU) to an input sequence.

Ascend

mindspore.ops.DynamicRNN

Applies a recurrent neural network to the input.

Ascend

mindspore.ops.Elu

Computes exponential linear:

Ascend GPU CPU

mindspore.ops.FastGeLU

Fast Gaussian Error Linear Units activation function.

Ascend

mindspore.ops.Flatten

Flattens a tensor without changing its batch size on the 0-th axis.

Ascend GPU CPU

mindspore.ops.FloorMod

Computes the remainder of division element-wise.

Ascend GPU CPU

mindspore.ops.FusedSparseAdam

Merges the duplicate value of the gradient and then updates parameters by the Adaptive Moment Estimation (Adam) algorithm.

Ascend CPU

mindspore.ops.FusedSparseLazyAdam

Merges the duplicate value of the gradient and then updates parameters by the Adaptive Moment Estimation (LazyAdam) algorithm.

Ascend CPU

mindspore.ops.FusedSparseProximalAdagrad

Merges the duplicate value of the gradient and then updates relevant entries according to the proximal adagrad algorithm.

CPU

mindspore.ops.GeLU

Gaussian Error Linear Units activation function.

Ascend GPU CPU

mindspore.ops.GetNext

Returns the next element in the dataset queue.

Ascend GPU

mindspore.ops.HSigmoid

Hard sigmoid activation function.

GPU CPU

mindspore.ops.HSwish

Hard swish activation function.

GPU CPU

mindspore.ops.KLDivLoss

Computes the Kullback-Leibler divergence between the target and the output.

GPU

mindspore.ops.L2Loss

Calculates half of the L2 norm of a tensor without using the sqrt.

Ascend GPU

mindspore.ops.L2Normalize

L2 Normalization Operator.

Ascend GPU CPU

mindspore.ops.LARSUpdate

Conducts LARS (layer-wise adaptive rate scaling) update on the sum of squares of gradient.

Ascend

mindspore.ops.LayerNorm

Applies the Layer Normalization to the input tensor.

Ascend GPU CPU

mindspore.ops.LogSoftmax

Log Softmax activation function.

Ascend GPU CPU

mindspore.ops.LRN

Local Response Normalization.

Ascend

mindspore.ops.LSTM

Performs the Long Short-Term Memory (LSTM) on the input.

GPU CPU

mindspore.ops.MaxPool

Max pooling operation.

Ascend GPU CPU

mindspore.ops.MaxPool3D

3D max pooling operation.

Ascend

mindspore.ops.MaxPoolWithArgmax

Performs max pooling on the input Tensor and returns both max values and indices.

Ascend GPU

mindspore.ops.MirrorPad

Pads the input tensor according to the paddings and mode.

Ascend GPU CPU

mindspore.ops.Mish

Computes MISH(A Self Regularized Non-Monotonic Neural Activation Function) of input tensors element-wise.

Ascend

mindspore.ops.NLLLoss

Gets the negative log likelihood loss between logits and labels.

Ascend GPU

mindspore.ops.OneHot

Computes a one-hot tensor.

Ascend GPU CPU

mindspore.ops.Pad

Pads the input tensor according to the paddings.

Ascend GPU CPU

mindspore.ops.PReLU

Parametric Rectified Linear Unit activation function.

Ascend GPU

mindspore.ops.ReLU

Computes ReLU (Rectified Linear Unit) of input tensors element-wise.

Ascend GPU CPU

mindspore.ops.ReLU6

Computes ReLU (Rectified Linear Unit) upper bounded by 6 of input tensors element-wise.

Ascend GPU CPU

mindspore.ops.ReLUV2

Computes ReLU (Rectified Linear Unit) of input tensors element-wise.

Ascend

mindspore.ops.ResizeBilinear

Resizes an image to a certain size using the bilinear interpolation.

Ascend CPU GPU

mindspore.ops.RNNTLoss

Computes the RNNTLoss and its gradient with respect to the softmax outputs.

Ascend

mindspore.ops.ROIAlign

Computes the Region of Interest (RoI) Align operator.

Ascend GPU

mindspore.ops.SeLU

Computes SeLU (scaled exponential Linear Unit) of input tensors element-wise.

Ascend

mindspore.ops.SGD

Computes the stochastic gradient descent.

Ascend GPU CPU

mindspore.ops.Sigmoid

Sigmoid activation function.

Ascend GPU CPU

mindspore.ops.SigmoidCrossEntropyWithLogits

Uses the given logits to compute sigmoid cross entropy between the target and the output.

Ascend GPU CPU

mindspore.ops.SmoothL1Loss

Computes smooth L1 loss, a robust L1 loss.

Ascend GPU CPU

mindspore.ops.Softmax

Softmax operation.

Ascend GPU CPU

mindspore.ops.SoftmaxCrossEntropyWithLogits

Gets the softmax cross-entropy value between logits and labels with one-hot encoding.

Ascend GPU CPU

mindspore.ops.Softplus

Softplus activation function.

Ascend GPU

mindspore.ops.Softsign

Softsign activation function.

Ascend

mindspore.ops.SparseApplyAdagrad

Updates relevant entries according to the adagrad scheme.

Ascend

mindspore.ops.SparseApplyAdagradV2

Updates relevant entries according to the adagrad scheme, one more epsilon attribute than SparseApplyAdagrad.

Ascend

mindspore.ops.SparseApplyProximalAdagrad

Updates relevant entries according to the proximal adagrad algorithm.

Ascend GPU

mindspore.ops.SparseSoftmaxCrossEntropyWithLogits

Computes the softmax cross-entropy value between logits and sparse encoding labels.

GPU CPU

mindspore.ops.Stack

Stacks a list of tensors in specified axis.

Ascend GPU CPU

mindspore.ops.Tanh

Tanh activation function.

Ascend GPU CPU

mindspore.ops.TopK

Finds values and indices of the k largest entries along the last dimension.

Ascend GPU CPU

mindspore.ops.Unstack

Unstacks tensor in specified axis.

Ascend GPU CPU

Math Operators

API Name

Description

Supported Platforms

mindspore.ops.Abs

Returns absolute value of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.AccumulateNV2

Computes accumulation of all input tensors element-wise.

Ascend

mindspore.ops.ACos

Computes arccosine of input tensors element-wise.

Ascend GPU CPU

mindspore.ops.Add

Adds two input tensors element-wise.

Ascend GPU CPU

mindspore.ops.AddN

Computes addition of all input tensors element-wise.

Ascend GPU CPU

mindspore.ops.ApproximateEqual

Returns True if abs(x1-x2) is smaller than tolerance element-wise, otherwise False.

Ascend

mindspore.ops.Asin

Computes arcsine of input tensors element-wise.

Ascend GPU CPU

mindspore.ops.Asinh

Computes inverse hyperbolic sine of the input element-wise.

Ascend GPU CPU

mindspore.ops.AssignAdd

Updates a Parameter by adding a value to it.

Ascend GPU CPU

mindspore.ops.AssignSub

Updates a Parameter by subtracting a value from it.

Ascend

mindspore.ops.Atan

Computes the trigonometric inverse tangent of the input element-wise.

Ascend GPU CPU

mindspore.ops.Atan2

Returns arctangent of x/y element-wise.

Ascend CPU GPU

mindspore.ops.Atanh

Computes inverse hyperbolic tangent of the input element-wise.

Ascend CPU

mindspore.ops.BatchMatMul

Computes matrix multiplication between two tensors by batch.

Ascend GPU CPU

mindspore.ops.BesselI0e

Computes BesselI0e of input element-wise.

Ascend

mindspore.ops.BesselI1e

Computes BesselI1e of input element-wise.

Ascend

mindspore.ops.BitwiseAnd

Returns bitwise and of two tensors element-wise.

Ascend

mindspore.ops.BitwiseOr

Returns bitwise or of two tensors element-wise.

Ascend

mindspore.ops.BitwiseXor

Returns bitwise xor of two tensors element-wise.

Ascend

mindspore.ops.Ceil

Rounds a tensor up to the closest integer element-wise.

Ascend

mindspore.ops.Cos

Computes cosine of input element-wise.

Ascend GPU CPU

mindspore.ops.Cosh

Computes hyperbolic cosine of input element-wise.

Ascend CPU

mindspore.ops.CumProd

Computes the cumulative product of the tensor x along axis.

Ascend GPU

mindspore.ops.CumSum

Computes the cumulative sum of input tensor along axis.

Ascend GPU CPU

mindspore.ops.Div

Computes the quotient of dividing the first input tensor by the second input tensor element-wise.

Ascend GPU CPU

mindspore.ops.DivNoNan

Computes a safe divide and returns 0 if the y is zero.

Ascend GPU

mindspore.ops.Eps

Creates a tensor filled with x dtype minimum value.

Ascend GPU CPU

mindspore.ops.Equal

Computes the equivalence between two tensors element-wise.

Ascend GPU CPU

mindspore.ops.EqualCount

Computes the number of the same elements of two tensors.

GPU CPU

mindspore.ops.Erf

Computes the Gauss error function of x element-wise.

Ascend GPU

mindspore.ops.Erfc

Computes the complementary error function of x element-wise.

Ascend GPU

mindspore.ops.Exp

Returns exponential of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.Expm1

Returns exponential then minus 1 of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.FloatStatus

Determines if the elements contain Not a Number(NaN), infinite or negative infinite.

GPU

mindspore.ops.Floor

Rounds a tensor down to the closest integer element-wise.

Ascend GPU CPU

mindspore.ops.FloorDiv

Divides the first input tensor by the second input tensor element-wise and round down to the closest integer.

Ascend GPU CPU

mindspore.ops.Greater

Computes the boolean value of \(x > y\) element-wise.

Ascend GPU CPU

mindspore.ops.GreaterEqual

Computes the boolean value of \(x >= y\) element-wise.

Ascend GPU CPU

mindspore.ops.HistogramFixedWidth

Returns a rank 1 histogram counting the number of entries in values that fall into every bin.

Ascend

mindspore.ops.IndexAdd

Adds tensor y to specified axis and indices of tensor x.

GPU

mindspore.ops.InplaceAdd

Adds v into specified rows of x.

Ascend

mindspore.ops.InplaceSub

Subtracts v into specified rows of x.

Ascend

mindspore.ops.Inv

Computes Inv(Reciprocal) of input tensor element-wise.

Ascend

mindspore.ops.Invert

Flips all bits of input tensor element-wise.

Ascend

mindspore.ops.IsInf

Determines which elements are inf or -inf for each position

GPU

mindspore.ops.IsNan

Determines which elements are NaN for each position.

GPU CPU

mindspore.ops.Less

Computes the boolean value of \(x < y\) element-wise.

Ascend GPU CPU

mindspore.ops.LessEqual

Computes the boolean value of \(x <= y\) element-wise.

Ascend GPU CPU

mindspore.ops.LinSpace

Generates values in an interval (inclusive of start and stop) and returns the corresponding interpolated array with num number of ticks.

Ascend GPU

mindspore.ops.Log

Returns the natural logarithm of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.Log1p

Returns the natural logarithm of one plus the input tensor element-wise.

Ascend GPU

mindspore.ops.LogicalAnd

Computes the "logical AND" of two tensors element-wise.

Ascend GPU CPU

mindspore.ops.LogicalNot

Computes the "logical NOT" of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.LogicalOr

Computes the "logical OR" of two tensors element-wise.

Ascend GPU CPU

mindspore.ops.MatMul

Multiplies matrix a and matrix b.

Ascend GPU CPU

mindspore.ops.MatrixInverse

Returns the inverse of the input matrix.

GPU

mindspore.ops.Maximum

Computes the maximum of input tensors element-wise.

Ascend GPU CPU

mindspore.ops.Minimum

Computes the minimum of input tensors element-wise.

Ascend GPU CPU

mindspore.ops.Mod

Computes the remainder of dividing the first input tensor by the second input tensor element-wise.

Ascend GPU CPU

mindspore.ops.Mul

Multiplies two tensors element-wise.

Ascend GPU CPU

mindspore.ops.MulNoNan

Computes x * y element-wise.

Ascend

mindspore.ops.Neg

Returns a tensor with negative values of the input tensor element-wise.

Ascend GPU CPU

mindspore.ops.NMSWithMask

When object detection problem is performed in the computer vision field, object detection algorithm generates a plurality of bounding boxes.

Ascend GPU

mindspore.ops.NotEqual

Computes the non-equivalence of two tensors element-wise.

Ascend GPU CPU

mindspore.ops.NPUAllocFloatStatus

Allocates a flag to store the overflow status.

Ascend

mindspore.ops.NPUClearFloatStatus

Clears the flag which stores the overflow status.

Ascend

mindspore.ops.NPUGetFloatStatus

Updates the flag which is the output tensor of NPUAllocFloatStatus with the latest overflow status.

Ascend

mindspore.ops.Pow

Computes a tensor to the power of the second input.

Ascend GPU CPU

mindspore.ops.RealDiv

Divides the first input tensor by the second input tensor in floating-point type element-wise.

Ascend GPU CPU

mindspore.ops.Reciprocal

Returns reciprocal of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.ReduceAll

Reduces a dimension of a tensor by the "logicalAND" of all elements in the dimension.

Ascend GPU CPU

mindspore.ops.ReduceAny

Reduces a dimension of a tensor by the "logical OR" of all elements in the dimension.

Ascend GPU CPU

mindspore.ops.ReduceMax

Reduces a dimension of a tensor by the maximum value in this dimension.

Ascend GPU CPU

mindspore.ops.ReduceMean

Reduces a dimension of a tensor by averaging all elements in the dimension.

Ascend GPU CPU

mindspore.ops.ReduceMin

Reduces a dimension of a tensor by the minimum value in the dimension.

Ascend GPU CPU

mindspore.ops.ReduceProd

Reduces a dimension of a tensor by multiplying all elements in the dimension.

Ascend

mindspore.ops.ReduceSum

Reduces a dimension of a tensor by summing all elements in the dimension.

Ascend GPU CPU

mindspore.ops.Round

Returns half to even of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.Rsqrt

Computes reciprocal of square root of input tensor element-wise.

Ascend GPU

mindspore.ops.Sign

Performs sign on the tensor element-wise.

Ascend CPU GPU

mindspore.ops.Sin

Computes sine of the input element-wise.

Ascend GPU CPU

mindspore.ops.Sinh

Computes hyperbolic sine of the input element-wise.

Ascend CPU

mindspore.ops.Sqrt

Returns square root of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.Square

Returns square of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.SquaredDifference

Subtracts the second input tensor from the first input tensor element-wise and returns square of it.

Ascend GPU CPU

mindspore.ops.SquareSumAll

Returns the square sum of a tensor element-wise

Ascend GPU

mindspore.ops.Sub

Subtracts the second input tensor from the first input tensor element-wise.

Ascend GPU CPU

mindspore.ops.Tan

Computes tangent of x element-wise.

Ascend CPU

mindspore.ops.TruncateDiv

Divides the first input tensor by the second input tensor element-wise for integer types, negative numbers will round fractional quantities towards zero.

Ascend

mindspore.ops.TruncateMod

Returns the remainder of division element-wise.

Ascend

mindspore.ops.Xdivy

Divides the first input tensor by the second input tensor element-wise.

Ascend

mindspore.ops.Xlogy

Computes the first input tensor multiplied by the logarithm of second input tensor element-wise.

Ascend

Array Operators

API Name

Description

Supported Platforms

mindspore.ops.ApplyFtrl

Updates relevant entries according to the FTRL scheme.

Ascend GPU

mindspore.ops.Argmax

Returns the indices of the maximum value of a tensor across the axis.

Ascend GPU CPU

mindspore.ops.ArgMaxWithValue

Calculates the maximum value with the corresponding index.

Ascend GPU

mindspore.ops.Argmin

Returns the indices of the minimum value of a tensor across the axis.

Ascend

mindspore.ops.ArgMinWithValue

Calculates the minimum value with corresponding index, and returns indices and values.

Ascend CPU

mindspore.ops.BatchToSpace

Divides batch dimension with blocks and interleaves these blocks back into spatial dimensions.

Ascend

mindspore.ops.BatchToSpaceND

Divides batch dimension with blocks and interleaves these blocks back into spatial dimensions.

Ascend

mindspore.ops.BroadcastTo

Broadcasts input tensor to a given shape.

Ascend GPU CPU

mindspore.ops.Cast

Returns a tensor with the new specified data type.

Ascend GPU CPU

mindspore.ops.Concat

Connect tensor in the specified axis.

Ascend GPU CPU

mindspore.ops.DepthToSpace

Rearranges blocks of depth data into spatial dimensions.

Ascend GPU CPU

mindspore.ops.DType

Returns the data type of the input tensor as mindspore.dtype.

Ascend GPU CPU

mindspore.ops.DynamicShape

Returns the shape of the input tensor.

Ascend GPU CPU

mindspore.ops.EditDistance

Computes the Levenshtein Edit Distance.

Ascend

mindspore.ops.EmbeddingLookup

Returns a slice of input tensor based on the specified indices.

Ascend CPU GPU

mindspore.ops.ExpandDims

Adds an additional dimension to 'input_x` at the given axis.

Ascend GPU CPU

mindspore.ops.Eye

Creates a tensor with ones on the diagonal and zeros the rest.

Ascend GPU CPU

mindspore.ops.Fill

Creates a tensor filled with a scalar value.

Ascend GPU CPU

mindspore.ops.FusedSparseFtrl

Merges the duplicate value of the gradient and then updates relevant entries according to the FTRL-proximal scheme.

Ascend CPU

mindspore.ops.Gather

Returns a slice of the input tensor based on the specified indices and axis.

Ascend GPU CPU

mindspore.ops.GatherD

Gathers values along an axis specified by dim.

Ascend GPU CPU

mindspore.ops.GatherNd

Gathers slices from a tensor by indices.

Ascend GPU CPU

mindspore.ops.Identity

Returns a Tensor with the same shape and contents as input.

Ascend CPU GPU

mindspore.ops.InplaceUpdate

Updates specified rows with values in v.

Ascend

mindspore.ops.InvertPermutation

Computes the inverse of an index permutation.

Ascend GPU CPU

mindspore.ops.IsFinite

Determines which elements are finite for each position.

Ascend GPU CPU

mindspore.ops.IsInstance

Checks whether an object is an instance of a target type.

Ascend GPU CPU

mindspore.ops.IsSubClass

Checks whether this type is a sub-class of another type.

Ascend GPU CPU

mindspore.ops.MaskedSelect

Returns a new 1-D Tensor which indexes the input tensor according to the boolean mask.

CPU

mindspore.ops.Meshgrid

Generates coordinate matrices from given coordinate tensors.

Ascend

mindspore.ops.Ones

Creates a tensor filled with value ones.

Ascend GPU CPU

mindspore.ops.OnesLike

Creates a new tensor.

Ascend GPU CPU

mindspore.ops.Padding

Extends the last dimension of the input tensor from 1 to pad_dim_size, by filling with 0.

Ascend

mindspore.ops.ParallelConcat

Concats tensor in the first dimension.

Ascend

mindspore.ops.Randperm

Generates n random samples from 0 to n-1 without repeating.

Ascend

mindspore.ops.Rank

Returns the rank of a tensor.

Ascend GPU CPU

mindspore.ops.Reshape

Reshapes the input tensor with the same values based on a given shape tuple.

Ascend GPU CPU

mindspore.ops.ResizeNearestNeighbor

Resizes the input tensor by using the nearest neighbor algorithm.

Ascend GPU CPU

mindspore.ops.ReverseSequence

Reverses variable length slices.

Ascend GPU

mindspore.ops.ReverseV2

Reverses specific dimensions of a tensor.

Ascend

mindspore.ops.Rint

Returns an integer that is closest to x element-wise.

Ascend GPU CPU

mindspore.ops.SameTypeShape

Checks whether the data type and shape of two tensors are the same.

Ascend GPU CPU

mindspore.ops.ScalarCast

Casts the input scalar to another type.

Ascend GPU CPU

mindspore.ops.ScalarToArray

Converts a scalar to a Tensor.

Ascend GPU CPU

mindspore.ops.ScalarToTensor

Converts a scalar to a Tensor, and converts the data type to the specified type.

Ascend GPU CPU

mindspore.ops.ScatterAdd

Updates the value of the input tensor through the addition operation.

Ascend GPU CPU

mindspore.ops.ScatterDiv

Updates the value of the input tensor through the divide operation.

Ascend CPU

mindspore.ops.ScatterMax

Updates the value of the input tensor through the maximum operation.

Ascend CPU

mindspore.ops.ScatterMin

Updates the value of the input tensor through the minimum operation.

Ascend CPU

mindspore.ops.ScatterMul

Updates the value of the input tensor through the multiply operation.

Ascend CPU

mindspore.ops.ScatterNd

Scatters a tensor into a new tensor depending on the specified indices.

Ascend GPU

mindspore.ops.ScatterNdAdd

Applies sparse addition to individual values or slices in a tensor.

Ascend

mindspore.ops.ScatterNdSub

Applies sparse subtraction to individual values or slices in a tensor.

Ascend

mindspore.ops.ScatterNdUpdate

Updates tensor values by using input indices and value.

Ascend GPU CPU

mindspore.ops.ScatterNonAliasingAdd

Applies sparse addition to the input using individual values or slices.

Ascend

mindspore.ops.ScatterSub

Updates the value of the input tensor through the subtraction operation.

Ascend CPU

mindspore.ops.ScatterUpdate

Updates tensor values by using input indices and value.

Ascend GPU CPU

mindspore.ops.Select

Returns the selected elements, either from input \(x\) or input \(y\), depending on the condition.

Ascend GPU CPU

mindspore.ops.Shape

Returns the shape of the input tensor.

Ascend GPU CPU

mindspore.ops.Size

Returns the size of a tensor.

Ascend GPU CPU

mindspore.ops.Slice

Slices a tensor in the specified shape.

Ascend GPU CPU

mindspore.ops.Sort

Sorts the elements of the input tensor along a given dimension in ascending order by value.

Ascend GPU

mindspore.ops.SpaceToBatch

Divides spatial dimensions into blocks and combines the block size with the original batch.

Ascend

mindspore.ops.SpaceToBatchND

Divides spatial dimensions into blocks and combines the block size with the original batch.

Ascend

mindspore.ops.SpaceToDepth

Rearranges blocks of spatial data into depth.

Ascend GPU CPU

mindspore.ops.SparseApplyFtrl

Updates relevant entries according to the FTRL-proximal scheme.

Ascend GPU

mindspore.ops.SparseApplyFtrlV2

Updates relevant entries according to the FTRL-proximal scheme.

Ascend

mindspore.ops.SparseGatherV2

Returns a slice of input tensor based on the specified indices and axis.

Ascend GPU

mindspore.ops.Split

Splits the input tensor into output_num of tensors along the given axis and output numbers.

Ascend GPU CPU

mindspore.ops.Squeeze

Returns a tensor with the same data type but dimensions of 1 are removed based on axis.

Ascend GPU CPU

mindspore.ops.StridedSlice

Extracts a strided slice of a tensor.

Ascend GPU CPU

mindspore.ops.TensorScatterAdd

Creates a new tensor by adding the values from the positions in input_x indicicated by indices, with values from update.

GPU

mindspore.ops.TensorScatterUpdate

Creates a new tensor by updating the positions in input_x indicicated by indices, with values from update.

Ascend GPU CPU

mindspore.ops.Tile

Replicates a tensor with given multiples times.

Ascend GPU CPU

mindspore.ops.Transpose

Permutes the dimensions of the input tensor according to input permutation.

Ascend GPU CPU

mindspore.ops.TupleToArray

Converts a tuple to a tensor.

Ascend GPU CPU

mindspore.ops.Unique

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.

Ascend GPU CPU

mindspore.ops.UniqueWithPad

Returns unique elements and relative indexes in 1-D tensor, filled with padding num.

Ascend CPU

mindspore.ops.UnsortedSegmentMax

Computes the maximum along segments of a tensor.

Ascend GPU

mindspore.ops.UnsortedSegmentMin

Computes the minimum of a tensor along segments.

Ascend GPU

mindspore.ops.UnsortedSegmentProd

Computes the product of a tensor along segments.

Ascend

mindspore.ops.UnsortedSegmentSum

Computes the sum of a tensor along segments.

Ascend GPU CPU

mindspore.ops.Zeros

Creates a tensor filled with value zeros.

Ascend GPU CPU

mindspore.ops.ZerosLike

Creates a new tensor.

Ascend GPU CPU

Communication Operators

API Name

Description

Supported Platforms

mindspore.ops.AllGather

Gathers tensors from the specified communication group.

Ascend GPU

mindspore.ops.AllReduce

Reduces the tensor data across all devices in such a way that all devices will get the same final result.

Ascend GPU

mindspore.ops.Broadcast

Broadcasts the tensor to the whole group.

Ascend GPU

mindspore.ops.ReduceOp

Operation options for reducing tensors.

Ascend GPU

mindspore.ops.ReduceScatter

Reduces and scatters tensors from the specified communication group.

Ascend GPU

Debug Operators

API Name

Description

Supported Platforms

mindspore.ops.HistogramSummary

Outputs the tensor to protocol buffer through histogram summary operator.

Ascend GPU CPU

mindspore.ops.ImageSummary

Outputs the image tensor to protocol buffer through image summary operator.

Ascend GPU CPU

mindspore.ops.InsertGradientOf

Attaches callback to the graph node that will be invoked on the node's gradient.

Ascend GPU CPU

mindspore.ops.Print

Outputs the tensor or string to stdout.

Ascend GPU

mindspore.ops.ScalarSummary

Outputs a scalar to a protocol buffer through a scalar summary operator.

Ascend GPU CPU

mindspore.ops.TensorSummary

Outputs a tensor to a protocol buffer through a tensor summary operator.

Ascend GPU CPU

Random Operators

API Name

Description

Supported Platforms

mindspore.ops.Gamma

Produces random positive floating-point values x, distributed according to probability density function:

Ascend

mindspore.ops.LogUniformCandidateSampler

Generates random labels with a log-uniform distribution for sampled_candidates.

Ascend

mindspore.ops.Multinomial

Returns a tensor sampled from the multinomial probability distribution located in the corresponding row of tensor input.

GPU

mindspore.ops.Poisson

Produces random non-negative integer values i, distributed according to discrete probability function:

Ascend

mindspore.ops.RandomCategorical

Generates random samples from a given categorical distribution tensor.

Ascend GPU

mindspore.ops.RandomChoiceWithMask

Generates a random sample as index tensor with a mask tensor from a given tensor.

Ascend GPU

mindspore.ops.StandardLaplace

Generates random numbers according to the Laplace random number distribution (mean=0, lambda=1).

Ascend

mindspore.ops.StandardNormal

Generates random numbers according to the standard Normal (or Gaussian) random number distribution.

Ascend GPU CPU

mindspore.ops.UniformCandidateSampler

Uniform candidate sampler.

GPU

mindspore.ops.UniformInt

Produces random integer values i, uniformly distributed on the closed interval [minval, maxval), that is, distributed according to the discrete probability function:

Ascend GPU

mindspore.ops.UniformReal

Produces random floating-point values i, uniformly distributed to the interval [0, 1).

Ascend GPU

Sponge Operators

API Name

Description

Supported Platforms

mindspore.ops.AngleAtomEnergy

Add the potential energy caused by angle terms to the total potential energy of each atom.

GPU

mindspore.ops.AngleEnergy

Calculate the energy caused by 3-atoms angle term.

GPU

mindspore.ops.AngleForce

Calculate the force exerted by angles made of 3 atoms on the corresponding atoms.

GPU

mindspore.ops.AngleForceWithAtomEnergy

Calculate angle force and potential energy together.

GPU

mindspore.ops.BondAtomEnergy

Add the potential energy caused by simple harmonic bonds to the total potential energy of each atom.

GPU

mindspore.ops.BondEnergy

Calculate the harmonic potential energy between each bonded atom pair.

GPU

mindspore.ops.BondForce

Calculate the force exerted by the simple harmonic bond on the corresponding atoms.

GPU

mindspore.ops.BondForceWithAtomEnergy

Calculate bond force and harmonic potential energy together.

GPU

mindspore.ops.BondForceWithAtomVirial

Calculate bond force and the virial coefficient caused by simple harmonic bond for each atom together.

GPU

mindspore.ops.DihedralAtomEnergy

Add the potential energy caused by dihedral terms to the total potential energy of each atom.

GPU

mindspore.ops.DihedralEnergy

Calculate the potential energy caused by dihedral terms for each 4-atom pair.

GPU

mindspore.ops.DihedralForce

Calculate the force exerted by the dihedral term which made of 4-atoms on the corresponding atoms.

GPU

mindspore.ops.DihedralForceWithAtomEnergy

Calculate dihedral force and potential energy together.

GPU

mindspore.ops.Dihedral14CFAtomEnergy

Add the potential energy caused by Coulumb energy correction for each necessary dihedral 1,4 terms to the total potential energy of each atom.

GPU

mindspore.ops.Dihedral14CFEnergy

Calculate the Coulumb part of 1,4 dihedral energy correction for each necessary dihedral terms on the corresponding atoms.

GPU

mindspore.ops.Dihedral14LJAtomEnergy

Add the potenrial energy caused by Lennard-Jones energy correction for each necessary dihedral 1,4 terms to the total potential energy of each atom.

GPU

mindspore.ops.Dihedral14LJCFForceWithAtomEnergy

Calculate the Lennard-Jones and Coulumb energy correction and force correction for each necessary dihedral 1,4 terms together and add them to the total force and potential energy for each atom.

GPU

mindspore.ops.Dihedral14LJEnergy

Calculate the Lennard-Jones part of 1,4 dihedral energy correction for each necessary dihedral terms on the corresponding atoms.

GPU

mindspore.ops.Dihedral14LJForce

Calculate the Lennard-Jones part of 1,4 dihedral force correction for each necessary dihedral terms on the corresponding atoms.

GPU

mindspore.ops.Dihedral14LJForceWithDirectCF

Calculate the Lennard-Jones part and the Coulomb part of force correction for each necessary dihedral 1,4 terms.

GPU

mindspore.ops.LJEnergy

Calculate the Van der Waals interaction energy described by Lennard-Jones potential for each atom.

GPU

mindspore.ops.LJForce

Calculate the Van der Waals interaction force described by Lennard-Jones potential energy for each atom.

GPU

mindspore.ops.LJForceWithPMEDirectForce

Calculate the Lennard-Jones force and PME direct force together.

GPU

mindspore.ops.MDIterationLeapFrog

One step of classical leap frog algorithm to solve the finite difference Hamiltonian equations of motion for certain system, using Langevin dynamics with Liu's thermostat scheme.

GPU

mindspore.ops.MDIterationLeapFrogLiujian

One step of classical leap frog algorithm to solve the finite difference Hamiltonian equations of motion for certain system, using Langevin dynamics with Liu's thermostat scheme.

GPU

mindspore.ops.NeighborListUpdate

Update (or construct if first time) the Verlet neighbor list for the calculation of short-ranged force.

GPU

mindspore.ops.PMEEnergy

Calculate the Coulumb energy of the system using PME method.

GPU

mindspore.ops.PMEExcludedForce

Calculate the excluded part of long-range Coulumb force using PME(Particle Meshed Ewald) method.

GPU

mindspore.ops.PMEReciprocalForce

Calculate the reciprocal part of long-range Coulumb force using PME(Particle Meshed Ewald) method.

GPU

Image Operators

API Name

Description

Supported Platforms

mindspore.ops.CropAndResize

Extracts crops from the input image tensor and resizes them.

Ascend GPU

Sparse Operators

API Name

Description

Supported Platforms

mindspore.ops.SparseToDense

Converts a sparse representation into a dense tensor.

CPU

mindspore.ops.SparseTensorDenseMatmul

Multiplies sparse matrix A by dense matrix B.

CPU

Other Operators

API Name

Description

Supported Platforms

mindspore.ops.Assign

Assigns Parameter with a value.

Ascend GPU CPU

mindspore.ops.BoundingBoxDecode

Decodes bounding boxes locations.

Ascend GPU

mindspore.ops.BoundingBoxEncode

Encodes bounding boxes locations.

Ascend GPU

mindspore.ops.CheckValid

Checks bounding box.

Ascend GPU

mindspore.ops.Depend

Depend is used for processing dependency operations.

Ascend GPU CPU

mindspore.ops.InTopK

Determines whether the targets are in the top k predictions.

Ascend GPU

mindspore.ops.IOU

Calculates intersection over union for boxes.

Ascend GPU CPU

mindspore.ops.NoRepeatNGram

Updates log_probs with repeat n-grams.

Ascend

mindspore.ops.PopulationCount

Calculates population count.

Ascend

composite

The composite operators are the pre-defined combination of operators.

API Name

Description

Supported Platforms

mindspore.ops.batch_dot

Computation of batch dot product between samples in two tensors containing batch dims.

Ascend GPU CPU

mindspore.ops.clip_by_global_norm

Clips tensor values by the ratio of the sum of their norms.

Ascend GPU

mindspore.ops.clip_by_value

Clips tensor values to a specified min and max.

Ascend GPU

mindspore.ops.core

A decorator that adds a flag to the function.

Ascend GPU CPU

mindspore.ops.count_nonzero

Count number of nonzero elements across axis of input tensor

Ascend GPU CPU

mindspore.ops.dot

Computation a dot product between samples in two tensors.

Ascend GPU CPU

mindspore.ops.gamma

Generates random numbers according to the Gamma random number distribution.

Ascend

mindspore.ops.GradOperation

A higher-order function which is used to generate the gradient function for the input function.

Ascend GPU CPU

mindspore.ops.HyperMap

Hypermap will apply the set operation to input sequences.

Ascend GPU CPU

mindspore.ops.laplace

Generates random numbers according to the Laplace random number distribution.

Ascend

mindspore.ops.matmul

Returns the matrix product of two arrays.

Ascend GPU CPU

mindspore.ops.multinomial

Returns a tensor sampled from the multinomial probability distribution located in the corresponding row of the input tensor.

GPU

mindspore.ops.MultitypeFuncGraph

Generates overloaded functions.

Ascend GPU CPU

mindspore.ops.normal

Generates random numbers according to the Normal (or Gaussian) random number distribution.

Ascend GPU CPU

mindspore.ops.poisson

Generates random numbers according to the Poisson random number distribution.

Ascend

mindspore.ops.repeat_elements

Repeat elements of a tensor along an axis, like np.repeat.

Ascend GPU CPU

mindspore.ops.sequence_mask

Returns a mask tensor representing the first N positions of each cell.

GPU

mindspore.ops.tensor_dot

Computation of Tensor contraction on arbitrary axes between tensors a and b.

Ascend GPU CPU

mindspore.ops.uniform

Generates random numbers according to the Uniform random number distribution.

Ascend GPU

functional

The functional operators are the pre-instantiated Primitive operators, which can be used directly as a function.

functional

Description

mindspore.ops.add

Refer to mindspore.ops.Add.

mindspore.ops.addn

Refer to mindspore.ops.AddN.

mindspore.ops.array_reduce

Reduce the dimension of the array.

mindspore.ops.array_to_scalar

Convert the array to a scalar.

mindspore.ops.assign

Refer to mindspore.ops.Assign.

mindspore.ops.assign_add

Refer to mindspore.ops.AssignAdd.

mindspore.ops.assign_sub

Refer to mindspore.ops.AssignSub.

mindspore.ops.bool_and

Calculate the result of logical AND operation.

mindspore.ops.bool_eq

Determine whether the Boolean values are equal.

mindspore.ops.bool_not

Calculate the result of logical NOT operation.

mindspore.ops.bool_or

Calculate the result of logical OR operation.

mindspore.ops.cast

Refer to mindspore.ops.Cast.

mindspore.ops.dtype

Refer to mindspore.ops.DType.

mindspore.ops.equal

Refer to mindspore.ops.Equal.

mindspore.ops.expand_dims

Refer to mindspore.ops.ExpandDims.

mindspore.ops.fill

Refer to mindspore.ops.Fill.

mindspore.ops.gather

Refer to mindspore.ops.Gather.

mindspore.ops.gather_nd

Refer to mindspore.ops.GatherNd.

mindspore.ops.hastype

Determine whether the object has the specified type.

mindspore.ops.in_dict

Determine whether the object is in the dict.

mindspore.ops.is_not

Determine whether the input is not the same as the other one.

mindspore.ops.is_

Determine whether the input is the same as the other one.

mindspore.ops.isconstant

Determine whether the object is constant.

mindspore.ops.isinstance_

Refer to mindspore.ops.IsInstance.

mindspore.ops.issubclass_

Refer to mindspore.ops.IsSubClass.

mindspore.ops.logical_and

Refer to mindspore.ops.LogicalAnd.

mindspore.ops.logical_not

Refer to mindspore.ops.LogicalNot.

mindspore.ops.logical_or

Refer to mindspore.ops.LogicalOr.

mindspore.ops.make_row_tensor

Generate row tensor.

mindspore.ops.make_sparse_tensor

Generate sparse tensor.

mindspore.ops.mixed_precision_cast

A temporary ops for mixed precision will be converted to cast after the step of compiling.

mindspore.ops.neg_tensor

Refer to mindspore.ops.Neg.

mindspore.ops.not_equal

Refer to mindspore.ops.NotEqual.

mindspore.ops.not_in_dict

Determine whether the object is not in the dict.

mindspore.ops.ones_like

Refer to mindspore.ops.OnesLike.

mindspore.ops.print_

Refer to mindspore.ops.Print.

mindspore.ops.rank

Refer to mindspore.ops.Rank.

mindspore.ops.reduced_shape

Calculate the shape of the reduction operator.

mindspore.ops.reshape

Refer to mindspore.ops.Reshape.

mindspore.ops.row_tensor_get_dense_shape

Get corresponding dense shape of row tensor.

mindspore.ops.row_tensor_get_indices

Get indices of row tensor.

mindspore.ops.row_tensor_get_values

Get values of row tensor.

mindspore.ops.same_type_shape

Refer to mindspore.ops.SameTypeShape.

mindspore.ops.scalar_add

Get the sum of two numbers.

mindspore.ops.scalar_cast

Refer to mindspore.ops.ScalarCast.

mindspore.ops.scalar_div

Get the quotient of dividing the first input number by the second input number.

mindspore.ops.scalar_eq

Determine whether two numbers are equal.

mindspore.ops.scalar_floordiv

Divide the first input number by the second input number and round down to the closest integer.

mindspore.ops.scalar_ge

Determine whether the number is greater than or equal to another number.

mindspore.ops.scalar_gt

Determine whether the number is greater than another number.

mindspore.ops.scalar_le

Determine whether the number is less than or equal to another number.

mindspore.ops.scalar_log

Get the natural logarithm of the input number.

mindspore.ops.scalar_lt

Determine whether the number is less than another number.

mindspore.ops.scalar_mod

Get the remainder of dividing the first input number by the second input number.

mindspore.ops.scalar_mul

Get the product of the input two numbers.

mindspore.ops.scalar_ne

Determine whether two numbers are not equal.

mindspore.ops.scalar_pow

Compute a number to the power of the second input number.

mindspore.ops.scalar_sub

Subtract the second input number from the first input number.

mindspore.ops.scalar_to_array

Refer to mindspore.ops.ScalarToArray.

mindspore.ops.scalar_to_tensor

Refer to mindspore.ops.ScalarToTensor.

mindspore.ops.scalar_uadd

Get the positive value of the input number.

mindspore.ops.scalar_usub

Get the negative value of the input number.

mindspore.ops.scatter_nd

Refer to mindspore.ops.ScatterNd.

mindspore.ops.scatter_nd_update

Refer to mindspore.ops.ScatterNdUpdate.

mindspore.ops.scatter_update

Refer to mindspore.ops.ScatterUpdate.

mindspore.ops.select

Refer to mindspore.ops.Select.

mindspore.ops.shape

Refer to mindspore.ops.Shape.

mindspore.ops.shape_mul

The input of shape_mul must be shape multiply elements in tuple(shape).

mindspore.ops.size

Refer to mindspore.ops.Size.

mindspore.ops.sparse_tensor_get_dense_shape

Get corresponding dense shape of sparse tensor.

mindspore.ops.sparse_tensor_get_indices

Get indices of sparse tensor.

mindspore.ops.sparse_tensor_get_values

Get values of sparse tensor.

mindspore.ops.sqrt

Refer to mindspore.ops.Sqrt.

mindspore.ops.square

Refer to mindspore.ops.Square.

mindspore.ops.stack

Refer to mindspore.ops.Stack.

mindspore.ops.stop_gradient

Disable update during back propagation. (stop_gradient)

mindspore.ops.strided_slice

Refer to mindspore.ops.StridedSlice.

mindspore.ops.string_concat

Concatenate two strings.

mindspore.ops.string_eq

Determine if two strings are equal.

mindspore.ops.tensor_div

Refer to mindspore.ops.RealDiv.

mindspore.ops.tensor_floordiv

Refer to mindspore.ops.FloorDiv.

mindspore.ops.tensor_ge

Refer to mindspore.ops.GreaterEqual.

mindspore.ops.tensor_gt

Refer to mindspore.ops.Greater.

mindspore.ops.tensor_le

Refer to mindspore.ops.LessEqual.

mindspore.ops.tensor_lt

Refer to mindspore.ops.Less.

mindspore.ops.tensor_mod

Refer to mindspore.ops.FloorMod.

mindspore.ops.tensor_mul

Refer to mindspore.ops.Mul.

mindspore.ops.tensor_pow

Refer to mindspore.ops.Pow.

mindspore.ops.tensor_sub

Refer to mindspore.ops.Sub.

mindspore.ops.tile

Refer to mindspore.ops.Tile.

mindspore.ops.tuple_to_array

Refer to mindspore.ops.TupleToArray.

mindspore.ops.typeof

Get type of object.

mindspore.ops.zeros_like

Refer to mindspore.ops.ZerosLike.

primitive

mindspore.ops.constexpr

Creates a PrimitiveWithInfer operator that can infer the value at compile time.

mindspore.ops.prim_attr_register

Primitive attributes register.

mindspore.ops.Primitive

Primitive is the base class of operator primitives in python.

mindspore.ops.PrimitiveWithCheck

PrimitiveWithCheck is the base class of primitives in python defines functions for checking operator input arguments but used the infer method registered in c++ source codes.

mindspore.ops.PrimitiveWithInfer

PrimitiveWithInfer is the base class of primitives in python and defines functions for tracking inference in python.

vm_impl_registry

mindspore.ops.get_vm_impl_fn

Gets the virtual implementation function by a primitive object or primitive name.

op_info_register

mindspore.ops.DataType

Ascend ops various combinations of dtype and format.

mindspore.ops.op_info_register

A decorator which is used to register an operator.

mindspore.ops.TBERegOp

Class for TBE operator information register.