mindspore.ops

operators that can be used for constructor function of Cell

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.8/resource/api_updates/ops_api_updates.md.

Operator Primitives

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, which defines functions to check the input arguments of operators, but uses 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.

Decorators

mindspore.ops.constexpr

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

mindspore.ops.custom_info_register

A decorator which is used to bind the registration information to the func parameter of mindspore.ops.Custom.

mindspore.ops.ms_kernel

The decorator of the Hybrid DSL function for the Custom Op.

mindspore.ops.op_info_register

A decorator which is used to register an operator.

mindspore.ops.prim_attr_register

Primitive attributes register.

Neural Network Layer Operators

Neural Network

API Name

Description

Supported Platforms

mindspore.ops.AvgPool

Average pooling operation.

Ascend GPU CPU

mindspore.ops.AvgPool3D

3D Average pooling operation.

Ascend CPU

mindspore.ops.BasicLSTMCell

It's similar to operator mindspore.ops.DynamicRNN.

Deprecated

mindspore.ops.BatchNorm

Batch Normalization for input data and updated parameters.

Ascend CPU GPU

mindspore.ops.Conv2D

2D convolution layer.

Ascend GPU CPU

mindspore.ops.Conv2DBackpropInput

The Conv2DBackpropInput interface is deprecated, please refer to mindspore.ops.Conv2DTranspose if you want to do unsampling.

Deprecated

mindspore.ops.Conv2DTranspose

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

Ascend GPU CPU

mindspore.ops.Conv3D

3D convolution layer.

Ascend GPU CPU

mindspore.ops.Conv3DTranspose

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

Ascend GPU

mindspore.ops.CTCGreedyDecoder

Performs greedy decoding on the logits given in inputs.

Ascend CPU

mindspore.ops.DepthwiseConv2dNative

DepthwiseConv2dNative will be deprecated in the future.

Deprecated

mindspore.ops.Dropout

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

Ascend GPU CPU

mindspore.ops.Dropout2D

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 NCHW, the channel feature map refers to a 2-dimensional feature map with the shape of HW).

Ascend GPU CPU

mindspore.ops.Dropout3D

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).

Ascend GPU CPU

mindspore.ops.DropoutDoMask

The DropoutDoMask interface is deprecated, please use the mindspore.ops.Dropout instead.

Deprecated

mindspore.ops.DropoutGenMask

The DropoutGenMask interface is deprecated, please use the mindspore.ops.Dropout instead.

Deprecated

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.Flatten

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

Ascend GPU CPU

mindspore.ops.LayerNorm

Applies the Layer Normalization to the input tensor.

Ascend GPU CPU

mindspore.ops.LRN

Local Response Normalization.

Ascend GPU CPU

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 GPU CPU

mindspore.ops.MaxPoolWithArgmax

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

Ascend GPU CPU

mindspore.ops.MirrorPad

Pads the input tensor according to the paddings and mode.

Ascend GPU CPU

mindspore.ops.Pad

Pads the input tensor according to the paddings.

Ascend GPU CPU

mindspore.ops.EmbeddingLookup

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

Ascend CPU GPU

mindspore.ops.Padding

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

Ascend GPU CPU

mindspore.ops.ResizeNearestNeighbor

Resizes the input tensor by using the nearest neighbor algorithm.

Ascend GPU CPU

mindspore.ops.ResizeBilinear

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

Ascend CPU GPU

Loss Function

API Name

Description

Supported Platforms

mindspore.ops.BCEWithLogitsLoss

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

Ascend GPU CPU

mindspore.ops.BinaryCrossEntropy

Computes the binary cross entropy between the logits and the labels.

Ascend GPU CPU

mindspore.ops.CTCLoss

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

Ascend GPU CPU

mindspore.ops.KLDivLoss

Computes the Kullback-Leibler divergence between the logits and the labels.

Ascend GPU

mindspore.ops.L2Loss

Calculates half of the L2 norm, but do not square the result.

Ascend GPU CPU

mindspore.ops.NLLLoss

Gets the negative log likelihood loss between logits and labels.

Ascend GPU CPU

mindspore.ops.RNNTLoss

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

Ascend

mindspore.ops.SigmoidCrossEntropyWithLogits

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

Ascend GPU CPU

mindspore.ops.SmoothL1Loss

Refer to mindspore.ops.smooth_l1_loss() for more detail.

Ascend GPU CPU

mindspore.ops.SoftMarginLoss

SoftMarginLoss operation.

Ascend

mindspore.ops.SoftmaxCrossEntropyWithLogits

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

Ascend GPU CPU

mindspore.ops.SparseSoftmaxCrossEntropyWithLogits

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

GPU CPU

Activation Function

API Name

Description

Supported Platforms

mindspore.ops.Elu

Exponential Linear Uint activation function.

Ascend GPU CPU

mindspore.ops.FastGeLU

Fast Gaussian Error Linear Units activation function.

Ascend GPU CPU

mindspore.ops.GeLU

Gaussian Error Linear Units activation function.

Ascend GPU CPU

mindspore.ops.HShrink

Hard Shrink activation function.

Ascend CPU GPU

mindspore.ops.HSigmoid

Hard sigmoid activation function.

Ascend GPU CPU

mindspore.ops.HSwish

Hard swish activation function.

Ascend GPU CPU

mindspore.ops.LogSoftmax

Log Softmax activation function.

Ascend GPU CPU

mindspore.ops.Mish

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

Ascend GPU CPU

mindspore.ops.PReLU

Parametric Rectified Linear Unit activation function.

Ascend GPU

mindspore.ops.ReLU

Computes ReLU (Rectified Linear Unit activation function) 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

The ReLUV2 interface is deprecated, please use the mindspore.ops.ReLU instead.

deprecated

mindspore.ops.SeLU

Activation function SeLU (Scaled exponential Linear Unit).

Ascend GPU CPU

mindspore.ops.Sigmoid

Sigmoid activation function.

Ascend GPU CPU

mindspore.ops.Softmax

Softmax operation.

Ascend GPU CPU

mindspore.ops.Softplus

Softplus activation function.

Ascend GPU CPU

mindspore.ops.SoftShrink

Applies the SoftShrink function element-wise.

Ascend CPU GPU

mindspore.ops.Softsign

Softsign activation function.

Ascend GPU CPU

mindspore.ops.Tanh

Tanh activation function.

Ascend GPU CPU

Optimizer

API Name

Description

Supported Platforms

mindspore.ops.Adam

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

Ascend GPU CPU

mindspore.ops.AdamNoUpdateParam

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

CPU

mindspore.ops.AdamWeightDecay

Updates gradients by the Adaptive Moment Estimation algorithm with weight decay (AdamWeightDecay).

Ascend GPU CPU

mindspore.ops.AdaptiveAvgPool2D

2D adaptive average pooling for temporal data.

GPU

mindspore.ops.ApplyAdadelta

Updates relevant entries according to the adadelta scheme.

Ascend CPU

mindspore.ops.ApplyAdagrad

Updates relevant entries according to the adagrad scheme.

Ascend CPU GPU

mindspore.ops.ApplyAdagradDA

Update var according to the proximal adagrad scheme.

Ascend GPU CPU

mindspore.ops.ApplyAdagradV2

Updates relevant entries according to the adagradv2 scheme.

Ascend CPU

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.ApplyFtrl

Updates relevant entries according to the FTRL scheme.

Ascend GPU CPU

mindspore.ops.ApplyGradientDescent

Updates var by subtracting alpha * delta from it.

Ascend GPU CPU

mindspore.ops.ApplyMomentum

Optimizer that implements the Momentum algorithm.

Ascend GPU CPU

mindspore.ops.ApplyPowerSign

Updates relevant entries according to the AddSign algorithm.

Ascend GPU CPU

mindspore.ops.ApplyProximalAdagrad

Updates relevant entries according to the proximal adagrad algorithm.

Ascend GPU CPU

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.FusedSparseAdam

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

Ascend 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.FusedSparseLazyAdam

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

Ascend CPU

mindspore.ops.FusedSparseProximalAdagrad

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

Ascend CPU

mindspore.ops.LARSUpdate

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

Ascend

mindspore.ops.SparseApplyAdagrad

Updates relevant entries according to the adagrad scheme.

Ascend CPU GPU

mindspore.ops.SparseApplyAdagradV2

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

Ascend CPU GPU

mindspore.ops.SparseApplyProximalAdagrad

Updates relevant entries according to the proximal adagrad algorithm.

Ascend GPU

mindspore.ops.SGD

Computes the stochastic gradient descent.

Ascend GPU CPU

mindspore.ops.SparseApplyFtrl

Updates relevant entries according to the FTRL-proximal scheme For more details, please refer to mindspore.nn.FTRL.

Ascend GPU CPU

mindspore.ops.SparseApplyFtrlV2

Updates relevant entries according to the FTRL-proximal scheme.

Ascend

Distance Function

API Name

Description

Supported Platforms

mindspore.ops.Cdist

Computes batched the p-norm distance between each pair of the two collections of row vectors.

Ascend CPU

mindspore.ops.EditDistance

Computes the Levenshtein Edit Distance.

Ascend

mindspore.ops.LpNorm

Returns the matrix norm or vector norm of a given tensor.

Ascend GPU CPU

Sampling Operator

API Name

Description

Supported Platforms

mindspore.ops.ComputeAccidentalHits

Compute accidental hits of sampled classes which match target classes.

Ascend

mindspore.ops.LogUniformCandidateSampler

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

Ascend

mindspore.ops.UniformCandidateSampler

Uniform candidate sampler.

Ascend GPU CPU

Image Processing

API Name

Description

Supported Platforms

mindspore.ops.BoundingBoxDecode

Decodes bounding boxes locations.

Ascend GPU CPU

mindspore.ops.BoundingBoxEncode

Encodes bounding boxes locations.

Ascend GPU CPU

mindspore.ops.CheckValid

Checks bounding box.

Ascend GPU CPU

mindspore.ops.CropAndResize

Extracts crops from the input image tensor and resizes them.

Ascend GPU CPU

mindspore.ops.ExtractVolumePatches

Extract patches from input and put them in the "depth" output dimension.

Ascend

mindspore.ops.IOU

Calculates intersection over union for boxes.

Ascend GPU CPU

mindspore.ops.L2Normalize

L2 Normalization Operator.

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 CPU

mindspore.ops.ROIAlign

Computes the Region of Interest (RoI) Align operator.

Ascend GPU CPU

Text Processing

API Name

Description

Supported Platforms

mindspore.ops.NoRepeatNGram

Updates log_probs with repeat n-grams.

Ascend CPU

Mathematical Operators

Element-wise Operator

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.Acosh

Computes inverse hyperbolic cosine of the inputs element-wise.

Ascend GPU CPU

mindspore.ops.Add

Adds two input tensors element-wise.

Ascend GPU CPU

mindspore.ops.Addcdiv

Performs the element-wise division of tensor x1 by tensor x2, multiply the result by the scalar value and add it to input_data.

Ascend CPU

mindspore.ops.Addcmul

Performs the element-wise product of tensor x1 and tensor x2, multiply the result by the scalar value and add it to input_data.

Ascend CPU

mindspore.ops.AddN

Computes addition of all input tensors element-wise.

Ascend GPU CPU

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.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.BesselI0e

Computes BesselI0e of input element-wise.

CPU GPU

mindspore.ops.BesselI1e

Computes BesselI1e of input element-wise.

CPU

mindspore.ops.BitwiseAnd

Returns bitwise and of two tensors element-wise.

Ascend CPU

mindspore.ops.BitwiseOr

Returns bitwise or of two tensors element-wise.

Ascend CPU

mindspore.ops.BitwiseXor

Returns bitwise xor of two tensors element-wise.

Ascend CPU

mindspore.ops.Ceil

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

Ascend GPU CPU

mindspore.ops.Conj

Returns a tensor of complex numbers that are the complex conjugate of each element in input.

Ascend GPU CPU

mindspore.ops.Cos

Computes cosine of input element-wise.

Ascend GPU CPU

mindspore.ops.Cosh

Computes hyperbolic cosine of input element-wise.

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 x2 is zero.

Ascend GPU CPU

mindspore.ops.Einsum

This operator uses equation to represent a tuple of tensors operations, you can use this operator to perform diagonal/reducesum/transpose/matmul/mul/inner product operations, etc.

GPU

mindspore.ops.Erf

Computes the Gauss error function of x element-wise.

Ascend GPU CPU

mindspore.ops.Erfc

Computes the complementary error function of x element-wise.

Ascend GPU CPU

mindspore.ops.Erfinv

Computes the inverse error function of input.

Ascend

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.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.FloorMod

Computes the remainder of division element-wise.

Ascend GPU CPU

mindspore.ops.Imag

Returns a new tensor containing imaginary value of the input.

GPU CPU

mindspore.ops.Inv

Computes Reciprocal of input tensor element-wise.

Ascend GPU CPU

mindspore.ops.Invert

Flips all bits of input tensor element-wise.

Ascend GPU CPU

mindspore.ops.Lerp

Computes the minimum of input tensors element-wise.

Ascend CPU

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 CPU

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.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 CPU

mindspore.ops.Neg

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

Ascend GPU CPU

mindspore.ops.Pow

Calculates the y power of each element in x.

Ascend GPU CPU

mindspore.ops.Real

Returns a Tensor that is the real part of the input.

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.Rint

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

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 CPU

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 GPU 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 CPU

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 GPU

mindspore.ops.Trunc

Returns a new tensor with the truncated integer values of the elements of input.

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 CPU GPU

mindspore.ops.TruncateMod

Returns the remainder of division element-wise.

Ascend CPU GPU

mindspore.ops.Xdivy

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

Ascend GPU CPU

mindspore.ops.Xlogy

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

Ascend CPU

Reduction Operator

API Name

Description

Supported Platforms

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 CPU

mindspore.ops.Argmin

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

Ascend CPU

mindspore.ops.ArgMinWithValue

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

Ascend GPU CPU

mindspore.ops.ReduceAll

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

Ascend GPU CPU

mindspore.ops.ReduceAny

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

Ascend GPU CPU

mindspore.ops.ReduceMax

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

Ascend GPU CPU

mindspore.ops.ReduceMean

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

Ascend GPU CPU

mindspore.ops.ReduceMin

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

Ascend GPU CPU

mindspore.ops.ReduceProd

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

Ascend GPU CPU

mindspore.ops.ReduceSum

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

Ascend GPU CPU

Comparison Operator

API Name

Description

Supported Platforms

mindspore.ops.ApproximateEqual

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

Ascend

mindspore.ops.CheckBprop

Checks whether the data type and the shape of corresponding elements from tuples x and y are the same.

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.

Ascend GPU CPU

mindspore.ops.Greater

Compare the value of the input parameters \(x,y\) element-wise, and the output result is a bool value.

Ascend GPU CPU

mindspore.ops.GreaterEqual

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

Ascend GPU CPU

mindspore.ops.InTopK

Determines whether the targets are in the top k predictions.

Ascend GPU CPU

mindspore.ops.IsFinite

Determines which elements are finite for each position.

Ascend GPU CPU

mindspore.ops.IsInf

Determines which elements are inf or -inf for each position

GPU CPU

mindspore.ops.IsInstance

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

Ascend GPU CPU

mindspore.ops.IsNan

Determines which elements are NaN for each position.

GPU CPU

mindspore.ops.IsSubClass

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

Ascend 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.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.NotEqual

Computes the non-equivalence of two tensors 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.TopK

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

Ascend GPU CPU

Linear Algebraic Operator

API Name

Description

Supported Platforms

mindspore.ops.BatchMatMul

Computes matrix multiplication between two tensors by batch.

Ascend GPU CPU

mindspore.ops.BiasAdd

Returns the sum of the input Tensor and the bias Tensor.

Ascend GPU CPU

mindspore.ops.Ger

Ger product of x1 and x2.

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 CPU

Tensor Operation Operator

Tensor Construction

API Name

Description

Supported Platforms

mindspore.ops.Eps

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 be expressed.

Ascend GPU CPU

mindspore.ops.Eye

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

Ascend GPU CPU

mindspore.ops.Fill

Create a Tensor of the specified shape and fill it with the specified value.

Ascend GPU CPU

mindspore.ops.LinSpace

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.

Ascend GPU CPU

mindspore.ops.OneHot

Computes a one-hot tensor.

Ascend GPU CPU

mindspore.ops.Ones

Creates a tensor filled with value ones.

Ascend GPU CPU

mindspore.ops.OnesLike

Returns a Tensor with a value of 1 and its shape and data type is the same as the input.

Ascend GPU CPU

mindspore.ops.Zeros

Creates a tensor filled with value zeros.

Ascend GPU CPU

mindspore.ops.ZerosLike

Returns a Tensor with a value of 0 and its shape and data type is the same as the input.

Ascend GPU CPU

Random Generation Operator

API Name

Description

Supported Platforms

mindspore.ops.Gamma

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

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 CPU

mindspore.ops.Randperm

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

Ascend GPU

mindspore.ops.StandardLaplace

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

Ascend CPU

mindspore.ops.StandardNormal

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

Ascend GPU CPU

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 CPU

mindspore.ops.UniformReal

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

Ascend GPU CPU

Array Operation

API Name

Description

Supported Platforms

mindspore.ops.BatchToSpace

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

Ascend GPU

mindspore.ops.BatchToSpaceND

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

Ascend CPU

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.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.DataFormatDimMap

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

Ascend GPU CPU

mindspore.ops.DepthToSpace

Rearrange 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

Same as operator TensorShape.

Deprecated

mindspore.ops.ExpandDims

Adds an additional dimension to input_x at the given axis.

Ascend GPU CPU

mindspore.ops.FloatStatus

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

GPU

mindspore.ops.Gather

Returns the slice of the input tensor corresponding to the elements of input_indices on the specified axis.

Ascend GPU CPU

mindspore.ops.GatherD

Gathers elements along an axis specified by dim.

Ascend GPU CPU

mindspore.ops.GatherNd

Gathers slices from a tensor by indices.

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.Identity

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

Ascend CPU GPU

mindspore.ops.IndexAdd

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

Ascend GPU CPU

mindspore.ops.InplaceAdd

Adds v into specified rows of x.

Ascend CPU

mindspore.ops.InplaceSub

Subtracts v into specified rows of x.

Ascend CPU

mindspore.ops.InplaceUpdate

Updates specified rows with values in v.

Ascend CPU

mindspore.ops.InvertPermutation

Computes the inverse of an index permutation.

Ascend GPU CPU

mindspore.ops.MaskedFill

Fills elements with value where mask is True.

Ascend GPU CPU

mindspore.ops.MaskedSelect

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

Ascend GPU CPU

mindspore.ops.Meshgrid

Generates coordinate matrices from given coordinate tensors.

Ascend CPU GPU

mindspore.ops.ParallelConcat

Concats tensor in the first dimension.

Ascend

mindspore.ops.PopulationCount

Computes element-wise population count(a.k.a bitsum, bitcount).

Ascend GPU CPU

mindspore.ops.Range

Creates a sequence of numbers that begins at start and extends by increments of delta up to but not including limit.

GPU CPU

mindspore.ops.Rank

Returns the rank of a tensor.

Ascend GPU CPU

mindspore.ops.Reshape

Rearranges the input Tensor based on the given shape.

Ascend GPU CPU

mindspore.ops.ReverseSequence

Reverses variable length slices.

Ascend GPU CPU

mindspore.ops.ReverseV2

Reverses specific dimensions of a tensor.

Ascend GPU

mindspore.ops.ScatterNd

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

Ascend GPU CPU

mindspore.ops.Select

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.

Ascend GPU CPU

mindspore.ops.Shape

Returns the shape of the input tensor.

Ascend GPU CPU

mindspore.ops.Size

Returns a Scalar of type int that represents the size of the input Tensor and the total number of elements in the 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 CPU

mindspore.ops.SpaceToBatch

SpaceToBatch is deprecated.

Deprecated

mindspore.ops.SpaceToBatchND

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

Ascend CPU

mindspore.ops.SpaceToDepth

Rearrange blocks of spatial data into depth.

Ascend GPU CPU

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.SplitV

Splits the input tensor into num_split tensors along the given dimension.

Ascend

mindspore.ops.Squeeze

Return the Tensor after deleting the dimension of size 1 in the specified axis.

Ascend GPU CPU

mindspore.ops.Stack

Stacks a list of tensors in specified 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 indicated by indices, with values from updates.

Ascend GPU CPU

mindspore.ops.TensorScatterDiv

Creates a new tensor by dividing the values from the positions in input_x indicated by indices, with values from updates.

GPU CPU

mindspore.ops.TensorScatterMax

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.

GPU

mindspore.ops.TensorScatterMin

By comparing the value at the position indicated by the index 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.

GPU

mindspore.ops.TensorScatterMul

Creates a new tensor by multiplying the values from the positions in input_x indicated by indices, with values from updates.

GPU CPU

mindspore.ops.TensorScatterSub

Creates a new tensor by subtracting the values from the positions in input_x indicated by indices, with values from updates.

Ascend GPU CPU

mindspore.ops.TensorScatterUpdate

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

Ascend GPU CPU

mindspore.ops.TensorShape

Returns the shape of the input tensor.

Ascend GPU CPU

mindspore.ops.Tile

Replicates an input 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.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 GPU CPU

mindspore.ops.UnsortedSegmentMax

Computes the maximum along segments of a tensor.

Ascend GPU CPU

mindspore.ops.UnsortedSegmentMin

Computes the minimum of a tensor along segments.

Ascend GPU CPU

mindspore.ops.UnsortedSegmentProd

Computes the product of a tensor along segments.

Ascend GPU

mindspore.ops.UnsortedSegmentSum

Computes the sum of a tensor along segments.

Ascend GPU CPU

mindspore.ops.Unstack

Unstacks tensor in specified axis.

Ascend GPU CPU

Type Conversion

API Name

Description

Supported Platforms

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.TupleToArray

Converts a tuple to a tensor.

Ascend GPU CPU

Parameter Operation Operator

API Name

Description

Supported Platforms

mindspore.ops.Assign

Assigns Parameter with a value.

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 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 GPU

mindspore.ops.ScatterMin

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

Ascend GPU CPU

mindspore.ops.ScatterMul

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

Ascend CPU

mindspore.ops.ScatterNdAdd

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

Ascend GPU CPU

mindspore.ops.ScatterNdSub

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

Ascend GPU CPU

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 GPU

mindspore.ops.ScatterUpdate

Updates tensor values by using input indices and value.

Ascend GPU CPU

Data Operation Operator

API Name

Description

Supported Platforms

mindspore.ops.GetNext

Returns the next element in the dataset queue.

Ascend GPU

Communication Operator

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 Ascend tutorial for more details. For the GPU device, users need to prepare the host file and mpi, please see the GPU tutorial .

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 CPU

mindspore.ops.AlltoAll

AlltoAll is a collective operation.

Ascend

mindspore.ops.Broadcast

Broadcasts the tensor to the whole group.

Ascend GPU

mindspore.ops.NeighborExchange

NeighborExchange is a collective operation.

Ascend

mindspore.ops.NeighborExchangeV2

NeighborExchangeV2 is a collective operation.

Ascend

mindspore.ops.ReduceOp

Operation options for reducing tensors.

Ascend GPU

mindspore.ops.ReduceScatter

Reduces and scatters tensors from the specified communication group.

Ascend GPU

Debugging Operator

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.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

mindspore.ops.Print

Outputs the tensor or string to stdout.

Ascend GPU

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

Sparse Operator

API Name

Description

Supported Platforms

mindspore.ops.SparseTensorDenseMatmul

Multiplies sparse matrix A by dense matrix B.

CPU

mindspore.ops.SparseToDense

Converts a sparse representation into a dense tensor.

CPU

Other Operators

API Name

Description

Supported Platforms

mindspore.ops.Depend

Depend is used for processing dependency operations.

Ascend GPU CPU

mindspore.ops.GradOperation

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

Ascend GPU CPU

mindspore.ops.HookBackward

This operation is used as a tag to hook gradient in intermediate variables.

Ascend GPU CPU

mindspore.ops.HyperMap

Hypermap will apply the set operation to input sequences.

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.Map

Map will apply the set operation on input sequences.

Ascend GPU CPU

mindspore.ops.MultitypeFuncGraph

Generates overloaded functions.

Ascend GPU CPU

mindspore.ops.Partial

Makes a partial function instance.

Ascend GPU CPU

Operator Information Registration

mindspore.ops.AiCPURegOp

Class for AiCPU operator information register.

mindspore.ops.CustomRegOp

Class used for generating the registration information for the func parameter of mindspore.ops.Custom.

mindspore.ops.DataType

Various combinations of dtype and format of Ascend ops.

mindspore.ops.TBERegOp

Class for TBE operator information register.

mindspore.ops.get_vm_impl_fn

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

Customizing Operator

mindspore.ops.Custom

Custom primitive is used for user defined operators and is to enhance the expressive ability of built-in primitives.