mindspore.ops.primitive

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.primitive operators in MindSpore, please refer to the link API Updates .

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

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

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.

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 CPU

mindspore.ops.CTCGreedyDecoder

Performs greedy decoding on the logits given in inputs.

Ascend CPU

mindspore.ops.DataFormatVecPermute

Permute input tensor from src_format to dst_format.

GPU CPU

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

Performs fractional avg pooling on the input.

GPU CPU

mindspore.ops.FractionalMaxPool

Performs fractional max pooling on the input.

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

Applies a 3D max pooling over an input Tensor which can be regarded as a composition of 3D planes.

Ascend GPU CPU

mindspore.ops.MaxPool3DWithArgmax

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

GPU

mindspore.ops.MaxPoolWithArgmax

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

Ascend GPU CPU

mindspore.ops.MaxUnpool2D

Computes a partial inverse of MaxPool2D.

GPU CPU

mindspore.ops.MirrorPad

Pads the input tensor according to the paddings and mode.

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

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

Ascend CPU GPU

mindspore.ops.ResizeNearestNeighbor

Resizes the input tensor to a given size by using the nearest neighbor algorithm.

Ascend GPU CPU

mindspore.ops.UpsampleNearest3D

Performs nearest neighbor upsampling operation.

GPU CPU

mindspore.ops.UpsampleTrilinear3D

Performs upsampling with trilinear interpolation across 3dims for 5dim input Tensor.

GPU CPU

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 CPU

mindspore.ops.L2Loss

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

Ascend GPU CPU

mindspore.ops.MultilabelMarginLoss

MultilabelMarginLoss operation.

Ascend GPU

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

Calculate the smooth L1 loss, and the L1 loss function has robustness.

Ascend GPU CPU

mindspore.ops.SoftMarginLoss

SoftMarginLoss operation.

Ascend GPU

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 CPU

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

Activation function SeLU (Scaled exponential Linear Unit).

Ascend GPU CPU

mindspore.ops.Sigmoid

Sigmoid activation function.

Ascend GPU CPU

mindspore.ops.Softmax

Applies the Softmax operation to the input tensor on the specified axis.

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

Computes hyperbolic tangent of input element-wise.

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

Applies a 3D adaptive max pooling over an input signal composed of several input planes.

GPU CPU

mindspore.ops.ApplyAdadelta

Updates relevant entries according to the adadelta scheme.

Ascend CPU GPU

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

mindspore.ops.ApplyAdaMax

Updates relevant entries according to the adamax scheme.

Ascend GPU CPU

mindspore.ops.ApplyAddSign

Updates relevant entries according to the AddSign algorithm.

Ascend GPU CPU

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

mindspore.ops.ApplyRMSProp

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

Ascend GPU CPU

mindspore.ops.LARSUpdate

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

Ascend

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 CPU

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

mindspore.ops.EditDistance

Computes the Levenshtein Edit Distance.

Ascend CPU

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 CPU

mindspore.ops.UniformCandidateSampler

Uniform candidate sampler.

Ascend GPU CPU

Image Processing

API Name

Description

Supported Platforms

mindspore.ops.AdjustHue

Adjust hue of RGB images.

GPU CPU

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

Greedily selects a subset of bounding boxes in descending order of score.

Ascend CPU

mindspore.ops.CropAndResize

Extracts crops from the input image tensor and resizes them.

Ascend GPU CPU

mindspore.ops.ExtractGlimpse

Extracts glimpse from the input image tensor and return a window.

GPU CPU

mindspore.ops.ExtractVolumePatches

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

Ascend GPU CPU

mindspore.ops.HSVToRGB

Convert one or more images from HSV to RGB.

GPU CPU

mindspore.ops.IOU

Calculates intersection over union for boxes.

Ascend GPU CPU

mindspore.ops.L2Normalize

L2 Normalization Operator.

Ascend GPU CPU

mindspore.ops.NMSWithMask

Non-maximum Suppression.

Ascend GPU CPU

mindspore.ops.RGBToHSV

Convert one or more images from RGB to HSV.

GPU CPU

mindspore.ops.ROIAlign

Computes the Region of Interest (RoI) Align operator.

Ascend GPU CPU

mindspore.ops.SampleDistortedBoundingBoxV2

Generate a single randomly distorted bounding box for an image.

CPU

mindspore.ops.ScaleAndTranslate

Scale And Translate the input image tensor.

GPU CPU

Text Processing

API Name

Description

Supported Platforms

mindspore.ops.NoRepeatNGram

Updates the probability of occurrence of words with its corresponding n-grams.

Ascend GPU CPU

Mathematical Operators

API Name

Description

Supported Platforms

mindspore.ops.BesselJ0

Computes BesselJ0 of input element-wise.

GPU CPU

mindspore.ops.BesselJ1

Computes BesselJ1 of input element-wise.

GPU CPU

mindspore.ops.BesselK0

Computes BesselK0 of input element-wise.

GPU CPU

mindspore.ops.BesselK0e

Computes BesselK0e of input element-wise.

GPU CPU

mindspore.ops.BesselK1

Computes BesselK1 of input element-wise.

GPU CPU

mindspore.ops.BesselK1e

Computes BesselK1e of input element-wise.

GPU CPU

mindspore.ops.BesselY0

Computes BesselY0 of input element-wise.

GPU CPU

mindspore.ops.BesselY1

Computes BesselY1 of input element-wise.

GPU CPU

mindspore.ops.Betainc

Computes the regularized incomplete beta integral \(I_{x}(a, b)\).

Ascend GPU CPU

mindspore.ops.Bincount

Counts the number of occurrences of each value in an integer array.

Ascend GPU CPU

mindspore.ops.Bucketize

Bucketizes 'input' based on 'boundaries'.

GPU CPU

mindspore.ops.CompareAndBitpack

Compare values of x to threshold and pack resulting bits into a uint8.

Ascend GPU CPU

mindspore.ops.Complex

Returns a complex Tensor from the real part and the imag part.

GPU CPU

mindspore.ops.Gcd

Computes greatest common divisor of input tensors element-wise.

GPU CPU

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

mindspore.ops.BesselI0e

Computes BesselI0e of input element-wise.

Ascend GPU CPU

mindspore.ops.BesselI1e

Computes BesselI1e of input element-wise.

Ascend GPU CPU

mindspore.ops.BitwiseAnd

Returns bitwise and of two tensors element-wise.

Ascend CPU GPU

mindspore.ops.BitwiseOr

Returns bitwise or of two tensors element-wise.

Ascend CPU GPU

mindspore.ops.BitwiseXor

Returns bitwise xor of two tensors element-wise.

Ascend CPU GPU

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

Operates a safe division between x1 and x2 element-wise.

Ascend GPU CPU

mindspore.ops.Einsum

Sums the product of the elements of the input Tensor along dimensions specified notation based on the Einstein summation convention(Einsum).

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

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, and it's a flooring divide.

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

Calculate the linear interpolation between two tensors based on the weight parameter.

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

mindspore.ops.Neg

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

Ascend GPU CPU

mindspore.ops.NextAfter

Returns the next representable floating-point value after x1 towards x2 element-wise.

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

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

mindspore.ops.Trunc

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

Ascend GPU 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 GPU 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 along with the given axis for the input tensor and, returns the maximum values and indices.

Ascend GPU CPU

mindspore.ops.Argmin

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

Ascend GPU CPU

mindspore.ops.ArgMinWithValue

Calculates the minimum value along with the given axis for the input tensor, and returns the minimum values and indices.

Ascend GPU CPU

mindspore.ops.EuclideanNorm

Computes the euclidean norm of elements across dimensions of a tensor.

GPU

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

Returns the standard-deviation and mean of each row of the input tensor in the dimension axis.

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

Ascend GPU CPU

mindspore.ops.IsNan

Determines which elements are NaN for each position.

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

mindspore.ops.RandomCategorical

Generates random samples from a given categorical distribution tensor.

Ascend GPU CPU

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

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

Computes the eigenvalues and eigenvectors of a square matrix(batch square matrices).

Ascend CPU

mindspore.ops.Expand

Returns a new view of the self tensor with singleton dimensions expanded to a larger size.

Ascend CPU

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

Fill the main diagonal of a tensor that has at least 2-dimensions.

GPU CPU

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

Computes the hamming window function with input window length.

GPU CPU

mindspore.ops.Histogram

Computes the histogram of a tensor.

CPU

mindspore.ops.HistogramFixedWidth

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

Ascend GPU

mindspore.ops.Identity

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

Ascend GPU CPU

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

mindspore.ops.InvertPermutation

Computes the inverse of an index permutation.

Ascend GPU CPU

mindspore.ops.Lcm

Computes least common multiplier of input tensors element-wise.

GPU CPU

mindspore.ops.LeftShift

Shift the value of each position of the tensor to the left several bits.

GPU CPU

mindspore.ops.ListDiff

Computes the difference between two lists of numbers.

GPU CPU

mindspore.ops.MatrixDiagPartV3

Returns the diagonal part of a tensor.

Ascend GPU CPU

mindspore.ops.MatrixDiagV3

Returns a batched diagonal tensor with given batched diagonal values.

Ascend GPU CPU

mindspore.ops.LogSpace

Returns a one-dimensional tensor of size steps whose values are evenly spaced from \(base^{start}\) to \(base^{end}\) , inclusive, on a logarithmic scale with base.

GPU CPU

mindspore.ops.Lstsq

Computes the solutions of the least squares and minimum norm problems of full-rank matrix x of size \((m \times n)\) and matrix a of size \((m \times k)\).

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

Computes the matrix exponential of a square matrix.

CPU

mindspore.ops.MatrixPower

Computes the n-th power of a batch of square matrices.

Ascend CPU

mindspore.ops.Meshgrid

Generates coordinate matrices from given coordinate tensors.

Ascend CPU GPU

mindspore.ops.ParallelConcat

Concats input tensors along the first dimension.

Ascend GPU CPU

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.

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

Resizes the input tensor to specific size by using the nearest neighbor algorithm.

CPU

mindspore.ops.ReverseSequence

Reverses variable length slices.

Ascend GPU CPU

mindspore.ops.ReverseV2

Reverses specific dimensions of a tensor.

Ascend GPU CPU

mindspore.ops.RightShift

Shift the value of each position of Tensor input_x to the right by corresponding bits in Tensor input_y.

Ascend GPU CPU

mindspore.ops.Roll

Rolls the elements of a tensor along an axis.

Ascend GPU

mindspore.ops.ScatterAddWithAxis

The output of the operation is produced by creating a copy of the input input_x, and then add updating its value to values specified by updates at specific index positions specified by indices.

CPU

mindspore.ops.ScatterNd

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

Ascend GPU CPU

mindspore.ops.ScatterNdDiv

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

GPU CPU

mindspore.ops.ScatterNdMax

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

Ascend GPU CPU

mindspore.ops.ScatterNdMul

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

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 the given dimension in the specified order.

Ascend GPU CPU

mindspore.ops.SpaceToBatchND

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

Ascend GPU 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.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.STFT

STFTs can be used as a way of quantifying the change of a nonstationary signal’s frequency and phase content over time.

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 CPU

mindspore.ops.TensorScatterMin

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.

Ascend GPU CPU

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

Returns a new tensor that is the sum of the input trace.

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 CPU

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

NeighborExchangeV2 is a collective communication 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.Assert

Asserts whether the given condition is True.

GPU CPU

mindspore.ops.HistogramSummary

This operator will calculate the histogram of a tensor and put it to a summary file with protocol buffer format.

Ascend GPU CPU

mindspore.ops.ImageSummary

This operator will put an image tensor to a summary file with protocol buffer format.

Ascend GPU CPU

mindspore.ops.ScalarSummary

This operator will put a scalar to a summary file with protocol buffer format.

Ascend GPU CPU

mindspore.ops.TensorSummary

This operator will put a tensor to a summary file with protocol buffer format.

Ascend GPU CPU

mindspore.ops.Print

Print the inputs to stdout.

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

mindspore.ops.NPUGetFloatStatus updates the flag which is the output tensor of mindspore.ops.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.

GPU CPU

Frame 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

MultitypeFuncGraph is a class used to generate overloaded functions, considering different types as inputs.

Ascend GPU CPU

mindspore.ops.Partial

Makes a partial function instance.

Ascend GPU CPU

mindspore.ops.StopGradient

StopGradient is used for eliminating the effect of a value on the gradient, such as truncating the gradient propagation from an output of a function.

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

API Name

Description

Supported Platforms

mindspore.ops.Custom

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

Ascend GPU CPU

Spectral Operator

API Name

Description

Supported Platforms

mindspore.ops.BartlettWindow

Bartlett window function.

GPU CPU

mindspore.ops.BlackmanWindow

Blackman window function.

GPU CPU