mindspore.ops.primitive

operators that can be used for constructor function of Cell

For more information about dynamic shape support status, please refer to Dynamic Shape Support Status of primitive Interface .

For more information about the support for the bfloat16 data type, please refer to Support List .

For the details about the usage constraints of each operator in the operator parallel process, refer to Usage Constraints During Operator Parallel .

The module import method is as follows:

import mindspore.ops as ops

Compared with the previous version, the added, deleted and supported platforms change information of mindspore.ops.primitive operators in MindSpore, please refer to the link mindspore.ops.primitive API Interface Change .

Operator Primitives

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.

Neural Network Layer Operators

Neural Network

API Name

Description

Supported Platforms

Warning

mindspore.ops.AvgPool

Average pooling operation.

Ascend GPU CPU

None

mindspore.ops.AvgPool3D

3D Average pooling operation.

Ascend GPU CPU

"kernel_size" is in the range [1, 255]. "strides" is in the range [1, 63].

mindspore.ops.BatchNorm

Batch Normalization for input data and updated parameters.

Ascend GPU CPU

If the operation is used for inference, and outputs "reserve_space_1" and "reserve_space_2" are available, then "reserve_space_1" has the same value as "mean" and "reserve_space_2" has the same value as "variance". For Ascend 310, the result accuracy fails to reach 1‰ due to the square root instruction.

mindspore.ops.Conv2D

2D convolution layer.

Ascend GPU CPU

None

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

None

mindspore.ops.Conv3D

3D convolution layer.

Ascend GPU CPU

None

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

None

mindspore.ops.CTCGreedyDecoder

Performs greedy decoding on the logits given in inputs.

Ascend GPU CPU

None

mindspore.ops.Dense

Refer to mindspore.ops.dense() for more details.

Ascend GPU CPU

None

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

None

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 \((N, C, H, W)\), the channel feature map refers to a 2-dimensional feature map with the shape of \((H, W)\)).

Ascend GPU CPU

None

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

None

mindspore.ops.DynamicGRUV2

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

Ascend

None

mindspore.ops.DynamicRNN

Applies a recurrent neural network to the input.

Ascend

None

mindspore.ops.Flatten

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

Ascend GPU CPU

None

mindspore.ops.FractionalMaxPool3DWithFixedKsize

Applies a 3D fractional max pooling to an input signal composed of multiple input planes.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.GridSampler2D

This operation samples 2d input_x by using interpolation based on flow field grid, which is usually gennerated by mindspore.ops.affine_grid().

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.GridSampler3D

Given an input and a grid, the output is calculated using the input values and pixel positions in the grid.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.LayerNorm

Applies the Layer Normalization to the input tensor.

Ascend GPU CPU

None

mindspore.ops.LRN

Local Response Normalization.

GPU CPU

LRN is deprecated on Ascend due to potential accuracy problem. It's recommended to use other normalization methods, e.g. mindspore.ops.BatchNorm.

mindspore.ops.LSTM

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

GPU CPU

None

mindspore.ops.MaxPool

Max pooling operation.

Ascend GPU CPU

None

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

None

mindspore.ops.MaxPool3DWithArgmax

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

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.MaxUnpool2D

Calculates the partial inverse of MaxPool2D operation.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.MaxUnpool3D

Computes the inverse of mindspore.ops.MaxPool3D.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.MirrorPad

Pads the input tensor according to the paddings and mode.

Ascend GPU CPU

None

mindspore.ops.Pad

Pads the input tensor according to the paddings.

Ascend GPU CPU

None

mindspore.ops.EmbeddingLookup

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

Ascend GPU CPU

None

mindspore.ops.Padding

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

Ascend GPU CPU

None

mindspore.ops.ResizeBicubic

Resize images to size using bicubic interpolation.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.ResizeNearestNeighbor

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

Ascend GPU CPU

None

Loss Function

API Name

Description

Supported Platforms

Warning

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

None

mindspore.ops.BinaryCrossEntropy

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

Ascend GPU CPU

The value of \(x\) must range from 0 to 1.

mindspore.ops.CTCLoss

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

Ascend GPU CPU

None

mindspore.ops.CTCLossV2

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

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.KLDivLoss

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

Ascend GPU CPU

None

mindspore.ops.L2Loss

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

Ascend GPU CPU

None

mindspore.ops.MultilabelMarginLoss

Creates a loss criterion that minimizes the hinge loss for multi-class classification tasks.

Ascend GPU

None

mindspore.ops.MultiMarginLoss

Creates a loss function that minimizes the hinge loss for multi-class classification tasks.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.NLLLoss

Gets the negative log likelihood loss between logits and labels.

Ascend GPU CPU

None

mindspore.ops.RNNTLoss

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

Ascend

None

mindspore.ops.SigmoidCrossEntropyWithLogits

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

Ascend GPU CPU

None

mindspore.ops.SmoothL1Loss

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

Ascend GPU CPU

None

mindspore.ops.SoftMarginLoss

SoftMarginLoss operation.

Ascend GPU

None

mindspore.ops.SoftmaxCrossEntropyWithLogits

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

Ascend GPU CPU

None

mindspore.ops.SparseSoftmaxCrossEntropyWithLogits

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

GPU CPU

None

mindspore.ops.TripletMarginLoss

TripletMarginLoss operation.

GPU

None

Activation Function

API Name

Description

Supported Platforms

Warning

mindspore.ops.CeLU

Refer to mindspore.ops.celu() for more details.

Ascend GPU CPU

None

mindspore.ops.Elu

Refer to mindspore.ops.elu() for more details.

Ascend GPU CPU

None

mindspore.ops.FastGeLU

Refer to mindspore.ops.fast_gelu() for more details.

Ascend GPU CPU

None

mindspore.ops.GeLU

Gaussian Error Linear Units activation function.

Ascend GPU CPU

None

mindspore.ops.GLU

Computes GLU (Gated Linear Unit activation function) of input tensors.

Ascend CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.HShrink

Hard Shrink activation function.

Ascend GPU CPU

None

mindspore.ops.HSigmoid

Hard sigmoid activation function.

Ascend GPU CPU

None

mindspore.ops.HSwish

Hard swish activation function.

Ascend GPU CPU

None

mindspore.ops.LogSoftmax

Refer to mindspore.ops.log_softmax() for more details.

Ascend GPU CPU

None

mindspore.ops.Mish

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

Ascend GPU CPU

None

mindspore.ops.PReLU

Refer to mindspore.ops.prelu() for more details.

Ascend GPU CPU

None

mindspore.ops.ReLU

Refer to mindspore.ops.relu() for more details.

Ascend GPU CPU

None

mindspore.ops.ReLU6

Refer to mindspore.ops.relu6() for more details.

Ascend GPU CPU

None

mindspore.ops.SeLU

Activation function SeLU (Scaled exponential Linear Unit).

Ascend GPU CPU

None

mindspore.ops.Sigmoid

Refer to mindspore.ops.sigmoid() for more details.

Ascend GPU CPU

None

mindspore.ops.Softmax

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

Ascend GPU CPU

None

mindspore.ops.Softplus

Softplus activation function.

Ascend GPU CPU

None

mindspore.ops.SoftShrink

Applies the SoftShrink function element-wise.

Ascend GPU CPU

None

mindspore.ops.Softsign

Softsign activation function.

Ascend GPU CPU

None

mindspore.ops.Tanh

Computes hyperbolic tangent of input element-wise.

Ascend GPU CPU

None

Optimizer

API Name

Description

Supported Platforms

Warning

mindspore.ops.Adam

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

Ascend GPU CPU

None

mindspore.ops.AdamWeightDecay

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

Ascend GPU CPU

None

mindspore.ops.AdaptiveAvgPool2D

AdaptiveAvgPool2D operation.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.AdaptiveAvgPool3D

AdaptiveAvgPool3D operation.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.ApplyAdadelta

Updates relevant entries according to the adadelta scheme.

Ascend GPU CPU

None

mindspore.ops.ApplyAdagrad

Updates relevant entries according to the adagrad scheme.

Ascend GPU CPU

None

mindspore.ops.ApplyAdagradDA

Update var according to the proximal adagrad scheme.

Ascend GPU CPU

None

mindspore.ops.ApplyAdagradV2

Updates relevant entries according to the adagradv2 scheme.

Ascend GPU CPU

None

mindspore.ops.ApplyAdaMax

Updates relevant entries according to the adamax scheme.

Ascend GPU CPU

None

mindspore.ops.ApplyAdamWithAmsgradV2

Update var according to the Adam algorithm.

Ascend GPU CPU

None

mindspore.ops.ApplyAddSign

Updates relevant entries according to the AddSign algorithm.

Ascend GPU CPU

None

mindspore.ops.ApplyCenteredRMSProp

Optimizer that implements the centered RMSProp algorithm.

Ascend GPU CPU

In dense implementation of this algorithm, mean_gradient, mean_square, and moment will update even if the grad is zero. But in this sparse implementation, mean_gradient, mean_square, and moment will not update in iterations during which the grad is zero.

mindspore.ops.ApplyFtrl

Updates relevant entries according to the FTRL scheme.

Ascend GPU CPU

None

mindspore.ops.ApplyGradientDescent

Updates var by subtracting alpha * delta from it.

Ascend GPU CPU

None

mindspore.ops.ApplyMomentum

Optimizer that implements the Momentum algorithm.

Ascend GPU CPU

None

mindspore.ops.ApplyPowerSign

Updates relevant entries according to the AddSign algorithm.

Ascend GPU CPU

None

mindspore.ops.ApplyProximalAdagrad

Updates relevant entries according to the proximal adagrad algorithm.

Ascend GPU CPU

None

mindspore.ops.ApplyProximalGradientDescent

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

Ascend GPU CPU

None

mindspore.ops.ApplyRMSProp

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

Ascend GPU CPU

Note that in dense implementation of this algorithm, "mean_square" and "moment" will update even if "grad" is 0, but in this sparse implementation, "mean_square" and "moment" will not update in iterations during which "grad" is 0.

mindspore.ops.LARSUpdate

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

Ascend

None

mindspore.ops.SparseApplyAdagradV2

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

Ascend GPU CPU

None

mindspore.ops.SparseApplyProximalAdagrad

Updates relevant entries according to the proximal adagrad algorithm.

Ascend GPU

None

mindspore.ops.SGD

Computes the stochastic gradient descent.

Ascend GPU CPU

None

mindspore.ops.SparseApplyFtrl

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

Ascend GPU CPU

None

mindspore.ops.SparseApplyFtrlV2

The SparseApplyFtrlV2 interface is deprecated, please use the mindspore.ops.SparseApplyFtrl instead.

Deprecated

None

Distance Function

API Name

Description

Supported Platforms

Warning

mindspore.ops.Cdist

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

Ascend GPU CPU

None

mindspore.ops.EditDistance

Computes the Levenshtein Edit Distance.

Ascend CPU

Unorded truth_indices or hypothesis_indices might lead to expected result, so it is suggested to make sure truth_indices and hypothesis_indices are both in ascending order before calling this API.

mindspore.ops.LpNorm

Return the p-norm of a matrix or vector.

Ascend GPU CPU

None

mindspore.ops.Pdist

Computes the p-norm distance between each pair of row vectors in the input.

GPU CPU

None

Sampling Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.ComputeAccidentalHits

Compute accidental hits of sampled classes which match target classes.

Ascend

None

mindspore.ops.LogUniformCandidateSampler

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

Ascend CPU

None

mindspore.ops.UniformCandidateSampler

Uniform candidate sampler.

Ascend GPU CPU

None

Image Processing

API Name

Description

Supported Platforms

Warning

mindspore.ops.BoundingBoxDecode

Decodes bounding boxes locations.

Ascend GPU CPU

None

mindspore.ops.BoundingBoxEncode

Encodes bounding boxes locations.

Ascend GPU CPU

None

mindspore.ops.CheckValid

Checks bounding box.

Ascend GPU CPU

None

mindspore.ops.CropAndResize

Extracts crops from the input image tensor and resizes them.

Ascend GPU CPU

None

mindspore.ops.ExtractVolumePatches

ops.ExtractVolumePatches is deprecated from version 2.3 and will be removed in a future version.

Deprecated

None

mindspore.ops.IOU

Calculates intersection over union for boxes.

Ascend GPU CPU

None

mindspore.ops.L2Normalize

L2 Normalization Operator.

Ascend GPU CPU

None

mindspore.ops.NMSWithMask

Non-maximum Suppression.

Ascend GPU CPU

Only supports up to 2864 input boxes at one time.

mindspore.ops.ResizeBilinearV2

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

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.ROIAlign

Computes the Region of Interest (RoI) Align operator.

Ascend GPU CPU

None

mindspore.ops.UpsampleNearest3D

Performs nearest neighbor upsampling operation.

Ascend GPU CPU

None

mindspore.ops.UpsampleTrilinear3D

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

Ascend GPU CPU

None

Text Processing

API Name

Description

Supported Platforms

Warning

mindspore.ops.NoRepeatNGram

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

Ascend GPU CPU

None

Feature Value Detection

API Name

Description

Supported Platforms

Warning

mindspore.ops.silent_check.ASDBase

ASDBase is the base class of operator with feature value detection feature in python.

Ascend

None

Mathematical Operators

API Name

Description

Supported Platforms

Warning

mindspore.ops.Bincount

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

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Cholesky

Performs the Cholesky decomposition on a single or a batch of symmetric positive-definite matrices.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Complex

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

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.ComplexAbs

Returns a Tensor that contains the magnitudes of the input.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Cross

Returns the cross product of vectors in dimension dim of x1 and x2.

Ascend CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.FFTWithSize

Fourier transform, can be adjusted by parameters to achieve FFT/IFFT/RFFT/IRFFT.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Gcd

Refer to mindspore.ops.gcd() for more details.

Ascend GPU CPU

None

Element-wise Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.Abs

Refer to mindspore.ops.abs() for more details.

Ascend GPU CPU

None

mindspore.ops.AccumulateNV2

Computes accumulation of all input tensors element-wise.

Ascend GPU

None

mindspore.ops.ACos

Refer to mindspore.ops.acos() for more details.

Ascend GPU CPU

None

mindspore.ops.Acosh

Refer to mindspore.ops.acosh() for more details.

Ascend GPU CPU

None

mindspore.ops.Add

Refer to mindspore.ops.add() for more details.

Ascend GPU CPU

None

mindspore.ops.Addcdiv

Adds the element-wise division of x1 by x2, multiplied by value to input_data.

Ascend GPU CPU

None

mindspore.ops.Addcmul

Adds the element-wise product of x1 by x2, multiplied by value to input_data.

Ascend GPU CPU

None

mindspore.ops.AddN

Computes addition of all input tensors element-wise.

Ascend GPU CPU

None

mindspore.ops.Angle

Refer to mindspore.ops.angle() for more details.

Ascend GPU CPU

None

mindspore.ops.Asin

Refer to mindspore.ops.asin() for more details.

Ascend GPU CPU

None

mindspore.ops.Asinh

Refer to mindspore.ops.asinh() for more details.

Ascend GPU CPU

None

mindspore.ops.Atan

Refer to mindspore.ops.atan() for more details.

Ascend GPU CPU

None

mindspore.ops.Atan2

Refer to mindspore.ops.atan2() for more details.

Ascend GPU CPU

None

mindspore.ops.Atanh

Refer to mindspore.ops.atanh() for more details.

Ascend GPU CPU

None

mindspore.ops.BesselI0

Computes modified Bessel function of the first kind, order 0 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BesselI0e

Computes exponential scaled modified Bessel function of the first kind, order 0 element-wise.

Ascend GPU CPU

None

mindspore.ops.BesselI1

Computes modified Bessel function of the first kind, order 1 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BesselI1e

Computes exponential scaled modified Bessel function of the first kind, order 1 element-wise.

Ascend GPU CPU

None

mindspore.ops.BesselJ0

Computes Bessel function of the first kind, order 0 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BesselJ1

Computes Bessel function of the first kind, order 1 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BesselK0

Computes modified Bessel function of the second kind, order 0 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BesselK0e

Computes exponential scaled modified Bessel function of the second kind, order 0 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BesselK1

Computes modified Bessel function of the second kind, order 1 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BesselK1e

Computes exponential scaled modified Bessel function of the second kind, order 1 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BesselY0

Computes Bessel function of the second kind, order 0 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BesselY1

Computes Bessel function of the second kind, order 1 element-wise.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BitwiseAnd

Returns bitwise and of two tensors element-wise.

Ascend GPU CPU

None

mindspore.ops.BitwiseOr

Returns bitwise or of two tensors element-wise.

Ascend GPU CPU

None

mindspore.ops.BitwiseXor

Returns bitwise xor of two tensors element-wise.

Ascend GPU CPU

None

mindspore.ops.Ceil

Refer to mindspore.ops.ceil() for more details.

Ascend GPU CPU

None

mindspore.ops.Conj

Refer to mindspore.ops.conj() for more details.

Ascend GPU CPU

None

mindspore.ops.Cos

Refer to mindspore.ops.cos() for more details.

Ascend GPU CPU

None

mindspore.ops.Cosh

Refer to mindspore.ops.cosh() for more details.

Ascend GPU CPU

None

mindspore.ops.Digamma

Computes the grad of the lgamma function on input.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Div

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

Ascend GPU CPU

None

mindspore.ops.DivNoNan

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

Ascend GPU CPU

None

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

None

mindspore.ops.Erf

Refer to mindspore.ops.erf() for more details.

Ascend GPU CPU

None

mindspore.ops.Erfc

Refer to mindspore.ops.erfc() for more details.

Ascend GPU CPU

None

mindspore.ops.Erfinv

Refer to mindspore.ops.erfinv() for more details.

Ascend GPU CPU

None

mindspore.ops.Exp

Refer to mindspore.ops.exp() for more details.

Ascend GPU CPU

None

mindspore.ops.Expm1

Refer to mindspore.ops.expm1() for more details.

Ascend GPU CPU

None

mindspore.ops.Floor

Refer to mindspore.ops.floor() for more details.

Ascend GPU CPU

None

mindspore.ops.FloorDiv

Refer to mindspore.ops.floor_divide() for more details.

Ascend GPU CPU

None

mindspore.ops.FloorMod

Refer to mindspore.ops.floor_mod() for more details.

Ascend GPU CPU

None

mindspore.ops.Geqrf

Refer to mindspore.ops.geqrf() for more details.

Ascend GPU CPU

None

mindspore.ops.Imag

Returns a new tensor containing imaginary value of the input.

Ascend GPU CPU

None

mindspore.ops.Inv

Computes Reciprocal of input tensor element-wise.

Ascend GPU CPU

None

mindspore.ops.Invert

Flips all bits of input tensor element-wise.

Ascend GPU CPU

None

mindspore.ops.Lerp

Does a linear interpolation of two tensors start and end based on a float or tensor weight.

Ascend GPU CPU

None

mindspore.ops.Log

Refer to mindspore.ops.log() for more details.

Ascend GPU CPU

None

mindspore.ops.Log1p

Refer to mindspore.ops.log1p() for more details.

Ascend GPU CPU

None

mindspore.ops.LogicalAnd

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

Ascend GPU CPU

None

mindspore.ops.LogicalNot

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

Ascend GPU CPU

None

mindspore.ops.LogicalOr

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

Ascend GPU CPU

None

mindspore.ops.LogicalXor

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

Ascend CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Logit

Calculate the logit of a tensor element-wise.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Mod

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

Ascend GPU CPU

The input data does not support 0. When the elements of input exceed 2048, the accuracy of operator cannot guarantee the requirement of double thousandths in the mini form. Due to different architectures, the calculation results of this operator on NPU and CPU may be inconsistent. If shape is expressed as \((D1, D2, ..., Dn)\), then \(D1*D2... *DN<=1000000,n<=8\).

mindspore.ops.Mul

Refer to mindspore.ops.mul() for more details.

Ascend GPU CPU

None

mindspore.ops.MulNoNan

Computes x * y element-wise.

Ascend GPU CPU

None

mindspore.ops.Neg

Refer to mindspore.ops.neg() for more details.

Ascend GPU CPU

None

mindspore.ops.NextAfter

Refer to mindspore.ops.nextafter() for more details.

Ascend GPU CPU

None

mindspore.ops.Pow

Refer to mindspore.ops.pow() for more details.

Ascend GPU CPU

None

mindspore.ops.Polar

Converts polar coordinates to Cartesian coordinates.

GPU CPU

None

mindspore.ops.Polygamma

Computes the \(a\).

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Real

Refer to mindspore.ops.real() for more details.

Ascend GPU CPU

None

mindspore.ops.RealDiv

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

Ascend GPU CPU

None

mindspore.ops.Reciprocal

Returns reciprocal of a tensor element-wise.

Ascend GPU CPU

None

mindspore.ops.Rint

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

Ascend GPU CPU

None

mindspore.ops.Round

Refer to mindspore.ops.round() for more details.

Ascend GPU CPU

None

mindspore.ops.Rsqrt

Refer to mindspore.ops.rsqrt() for more details.

Ascend GPU CPU

None

mindspore.ops.Sign

Performs sign on the tensor element-wise.

Ascend GPU CPU

None

mindspore.ops.Sin

Refer to mindspore.ops.sin() for more details.

Ascend GPU CPU

None

mindspore.ops.Sinc

Refer to mindspore.ops.sinc() for more details.

Ascend GPU CPU

None

mindspore.ops.Sinh

Refer to mindspore.ops.sinh() for more details.

Ascend GPU CPU

None

mindspore.ops.Sqrt

Refer to mindspore.ops.sqrt() for more details.

Ascend GPU CPU

None

mindspore.ops.Square

Refer to mindspore.ops.square() for more details.

Ascend GPU CPU

None

mindspore.ops.SquaredDifference

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

Ascend GPU CPU

None

mindspore.ops.SquareSumAll

Returns the square sum of a tensor element-wise.

Ascend GPU CPU

None

mindspore.ops.Sub

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

Ascend GPU CPU

None

mindspore.ops.Tan

Computes tangent of x element-wise.

Ascend GPU CPU

None

mindspore.ops.Trunc

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

Ascend GPU CPU

None

mindspore.ops.TruncateDiv

Divides the first input tensor by the second input tensor element-wise and rounds the results of division towards zero.

Ascend GPU CPU

None

mindspore.ops.TruncateMod

Returns the remainder of division element-wise.

Ascend GPU CPU

The input data does not support 0. When the elements of input exceed 2048, the accuracy of operator cannot guarantee the requirement of double thousandths in the mini form. Due to different architectures, the calculation results of this operator on NPU and CPU may be inconsistent. If shape is expressed as (D1,D2... ,Dn), then D1*D2... *DN<=1000000,n<=8.

mindspore.ops.Xdivy

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

Ascend GPU CPU

None

mindspore.ops.Xlogy

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

Ascend GPU CPU

None

mindspore.ops.Zeta

Compute the Hurwitz zeta function ζ(x,q) of input Tensor.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

Reduction Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.Argmax

Returns the indices of the maximum value along a specified axis of a Tensor.

Ascend GPU CPU

None

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

If there are multiple maximum values, the index of the first maximum value is used. The value range of axis is [-dims, dims - 1]. "dims" is the dimension length of input.

mindspore.ops.Argmin

Returns the indices of the minimum value along a specified axis of a Tensor.

Ascend GPU CPU

None

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

If there are multiple minimum values, the index of the first minimum value is used. The value range of axis is [-dims, dims - 1]. "dims" is the dimension length of input.

mindspore.ops.Median

Computes the median and its corresponding indices of input tensor in the axis dimension.

GPU CPU

indices does not necessarily contain the first occurrence of each median value found in the input, unless it is unique. The specific implementation of this API is device-specific. The results may be different on CPU and GPU. When attr global_median is True , the value of the second output tensor indices is meaningless.

mindspore.ops.ReduceAll

Refer to mindspore.ops.all() for more details.

Ascend GPU CPU

None

mindspore.ops.ReduceAny

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

Ascend GPU CPU

None

mindspore.ops.ReduceMax

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

Ascend GPU CPU

None

mindspore.ops.ReduceMean

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

Ascend GPU CPU

None

mindspore.ops.ReduceMin

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

Ascend GPU CPU

None

mindspore.ops.ReduceProd

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

Ascend GPU CPU

None

mindspore.ops.ReduceSum

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

Ascend GPU CPU

None

Comparison Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.ApproximateEqual

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

Ascend GPU CPU

None

mindspore.ops.Equal

Refer to mindspore.ops.equal() for more details.

Ascend GPU CPU

None

mindspore.ops.EqualCount

Computes the number of the same elements of two tensors.

Ascend GPU CPU

None

mindspore.ops.Greater

Refer to mindspore.ops.greater() for more details.

Ascend GPU CPU

None

mindspore.ops.GreaterEqual

Refer to mindspore.ops.greater_equal() for more details.

Ascend GPU CPU

None

mindspore.ops.InTopK

Determines whether the targets are in the top k predictions.

Ascend GPU CPU

None

mindspore.ops.IsFinite

Refer to mindspore.ops.isfinite() for more details.

Ascend GPU CPU

None

mindspore.ops.IsInf

Determines which elements are inf or -inf for each position.

Ascend GPU CPU

None

mindspore.ops.IsNan

Determines which elements are NaN for each position.

Ascend GPU CPU

None

mindspore.ops.Less

Refer to mindspore.ops.less() for more details.

Ascend GPU CPU

None

mindspore.ops.LessEqual

Refer to mindspore.ops.less_equal() for more details.

Ascend GPU CPU

None

mindspore.ops.Maximum

Refer to mindspore.ops.maximum() for more details.

Ascend GPU CPU

None

mindspore.ops.Minimum

Refer to mindspore.ops.minimum() for more details.

Ascend GPU CPU

None

mindspore.ops.NotEqual

Refer to mindspore.ops.not_equal() for more details.

Ascend GPU CPU

None

mindspore.ops.TopK

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

Ascend GPU CPU

If sorted is set to False, it will use the aicpu operator, the performance may be reduced. In addition, due to different memory layout and traversal methods on different platforms, the display order of calculation results may be inconsistent when sorted is False.

Linear Algebraic Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.BatchMatMul

Computes matrix multiplication between two tensors by batch.

Ascend GPU CPU

None

mindspore.ops.BiasAdd

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

Ascend GPU CPU

None

mindspore.ops.Ger

Ger product of x1 and x2.

Ascend GPU CPU

None

mindspore.ops.MatMul

Multiplies matrix a and matrix b.

Ascend GPU CPU

None

mindspore.ops.MatrixInverse

Returns the inverse of the input matrix.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Ormqr

Computes the matrix-matrix multiplication of a product of Householder matrices with a general matrix.

GPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Orgqr

Calculates the explicit representation of the orthogonal matrix \(Q\) returned by mindspore.ops.Geqrf.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Svd

Computes the singular value decompositions of one or more matrices.

GPU CPU

None

Tensor Operation Operator

Tensor Construction

API Name

Description

Supported Platforms

Warning

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

Ascend GPU CPU

None

mindspore.ops.Eye

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

Ascend GPU CPU

None

mindspore.ops.Fill

The Fill interface is deprecated, please use the mindspore.ops.FillV2 instead.

Deprecated

None

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

None

mindspore.ops.OneHot

Computes a one-hot tensor.

Ascend GPU CPU

None

mindspore.ops.Ones

Creates a tensor filled with value ones.

Ascend GPU CPU

For argument size, Tensor type input will be deprecated in the future version.

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

None

mindspore.ops.Zeros

Zeros will be deprecated in the future.

Ascend GPU CPU

For argument size, Tensor type input will be deprecated in the future version.

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

None

Random Generation Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.Bernoulli

Randomly set the elements of output to 0 or 1 with the probability of P which follows the Bernoulli distribution.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Gamma

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

Ascend

None

mindspore.ops.Multinomial

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

Ascend GPU CPU

None

mindspore.ops.MultinomialWithReplacement

Returns a tensor where each row contains numsamples indices sampled from the multinomial distribution with replacement.

CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.RandomCategorical

Generates random samples from a given categorical distribution tensor.

Ascend GPU CPU

None

mindspore.ops.RandomChoiceWithMask

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

Ascend GPU CPU

None

mindspore.ops.RandomGamma

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

CPU

None

mindspore.ops.RandomPoisson

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

GPU CPU

None

mindspore.ops.Randperm

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

Ascend GPU

None

mindspore.ops.RandpermV2

Refer to mindspore.ops.randperm() for more details.

CPU

None

mindspore.ops.StandardLaplace

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

Ascend GPU CPU

None

mindspore.ops.StandardNormal

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

Ascend GPU CPU

None

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

None

mindspore.ops.UniformReal

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

Ascend GPU CPU

None

Array Operation

API Name

Description

Supported Platforms

Warning

mindspore.ops.AffineGrid

Creates a 2D or 3D flow field (sampling grid) based on a batch of affine matrices theta.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BatchToSpace

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

Ascend GPU

None

mindspore.ops.BatchToSpaceND

Please use batch_to_space_nd instead.

Deprecated

None

mindspore.ops.BroadcastTo

Refer to mindspore.ops.broadcast_to() for more details.

Ascend GPU CPU

None

mindspore.ops.Cast

Returns a tensor with the new specified data type.

Ascend GPU CPU

None

mindspore.ops.ChannelShuffle

Divide the channels in a tensor of shape \((*, C, H, W)\) into \(g\) group and rearrange them as \((*, \frac C g, g, H*W)\), while keeping the original tensor shapes.

Ascend CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Col2Im

Rearranges a row vector to an image.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Concat

Refer to mindspore.ops.cat() for more details.

Ascend GPU CPU

None

mindspore.ops.Cummax

Refer to mindspore.ops.cummax() for more details.

GPU CPU

None

mindspore.ops.Cummin

Returns the cumulative minimum of elements and the index.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.CumProd

Computes the cumulative product of the tensor x along axis.

Ascend GPU CPU

None

mindspore.ops.CumSum

Computes the cumulative sum of input tensor along axis.

Ascend GPU CPU

None

mindspore.ops.DataFormatDimMap

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

Ascend GPU CPU

None

mindspore.ops.DepthToSpace

Rearrange blocks of depth data into spatial dimensions.

Ascend GPU CPU

None

mindspore.ops.Diag

Refer to mindspore.ops.diag() for more details.

Ascend GPU CPU

None

mindspore.ops.DType

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

Ascend GPU CPU

None

mindspore.ops.ExpandDims

Refer to mindspore.ops.expand_dims() for more details.

Ascend GPU CPU

None

mindspore.ops.FillDiagonal

Fills the main diagonal of a Tensor in-place with a specified value and returns the result.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.FillV2

Creates a tensor with shape described by shape and fills it with values in value .

Ascend GPU CPU

None

mindspore.ops.FloatStatus

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

GPU

None

mindspore.ops.Fmax

Computes the maximum of input tensors element-wise.

CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Gather

Refer to mindspore.ops.gather() for more details.

Ascend GPU CPU

None

mindspore.ops.GatherD

Refer to mindspore.ops.gather_d() for more details.

Ascend GPU CPU

None

mindspore.ops.GatherNd

Refer to mindspore.ops.gather_nd() for more details.

Ascend GPU CPU

None

mindspore.ops.HammingWindow

Computes the hamming window function with input window length.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Heaviside

Applies the Heaviside step function for input x element-wise.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.HistogramFixedWidth

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

Ascend GPU

None

mindspore.ops.Hypot

Computes hypotenuse of input tensors element-wise as legs of a right triangle.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Identity

Refer to mindspore.ops.deepcopy() for more details.

Ascend GPU CPU

None

mindspore.ops.Igamma

Calculates lower regularized incomplete Gamma function.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Igammac

Compute the upper regularized incomplete Gamma function Q(a, x).

Ascend GPU CPU

None

mindspore.ops.Im2Col

Extracts sliding local blocks from a batched input tensor.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.IndexAdd

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

Ascend GPU CPU

None

mindspore.ops.IndexFill

Fills the elements under the dim dimension of the input Tensor x with the input value by selecting the indices in the order given in index.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.IndexPut

According to the index number of indexes, replace the value corresponding to x1 with the value in x2.

Ascend CPU

None

mindspore.ops.InplaceAdd

Adds v into specified rows of x.

Ascend GPU CPU

None

mindspore.ops.InplaceIndexAdd

Adds Tensor updates to specified axis and indices of Tensor var element-wise.

Ascend CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.InplaceSub

Subtracts v into specified rows of x.

Ascend GPU CPU

None

mindspore.ops.InplaceUpdate

Please use mindspore.ops.InplaceUpdateV2 instead.

Deprecated

None

mindspore.ops.InplaceUpdateV2

Updates specified values in x to v according to indices.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.InvertPermutation

Computes the inverse of an index permutation.

Ascend GPU CPU

None

mindspore.ops.IsClose

Returns a tensor of Boolean values indicating whether two input tensors are element-wise equal within a given tolerance.

Ascend GPU CPU

None

mindspore.ops.Lcm

Computes least common multiplier of input tensors element-wise.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.LeftShift

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

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.LogSpace

Generates a 1-D Tensor with a length of steps.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.LuUnpack

Converts LU_data and LU_pivots back into P, L and U matrices, where P is a permutation matrix, L is a lower triangular matrix, and U is an upper triangular matrix.

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.MaskedFill

Refer to mindspore.ops.masked_fill() for more details.

Ascend GPU CPU

None

mindspore.ops.MaskedScatter

Updates the value in the input with value in updates according to the mask.

Ascend CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.MaskedSelect

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

Ascend GPU CPU

None

mindspore.ops.MatrixBandPart

Extracts the central diagonal band of each matrix in a tensor, with all values outside the central band set to zero.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.MatrixDiagPartV3

Returns the diagonal part of a tensor.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.MatrixDiagV3

Constructs a diagonal matrix or a batch of diagonal matrices from a given input Tensor.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.MatrixSetDiagV3

Updates the diagonal part of a batched tensor.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.MatrixSolve

Solves systems of linear equations.

Ascend CPU

None

mindspore.ops.Meshgrid

Generates coordinate matrices from given coordinate tensors.

Ascend GPU CPU

None

mindspore.ops.Mvlgamma

Calculates the multivariate log-gamma function element-wise for a given dimension p.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.NanToNum

Replaces NaN, positive infinity and negative infinity values in the input Tensor with the values specified by nan, posinf and neginf respectively.

Ascend CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.NonZero

Refer to mindspore.ops.nonzero() for more details.

Ascend GPU CPU

None

mindspore.ops.ParallelConcat

Concats input tensors along the first dimension.

Ascend GPU CPU

None

mindspore.ops.PopulationCount

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

Ascend GPU CPU

None

mindspore.ops.RandomShuffle

Randomly shuffles a Tensor along its first dimension.

Ascend GPU CPU

None

mindspore.ops.Range

Refer to mindspore.ops.range() for more details.

GPU CPU

None

mindspore.ops.Rank

Returns the rank of a tensor.

Ascend GPU CPU

None

mindspore.ops.Renorm

Renormalizes the sub-tensors along dimension dim, and each sub-tensor's p-norm should not exceed the 'maxnorm'.

Ascend GPU CPU

None

mindspore.ops.Reshape

Refer to mindspore.ops.reshape() for more details.

Ascend GPU CPU

None

mindspore.ops.ReverseSequence

Reverses variable length slices.

Ascend GPU CPU

None

mindspore.ops.ReverseV2

Refer to mindspore.ops.flip() for more details.

Ascend GPU CPU

None

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

This is an experimental API that is subject to change or deletion.

mindspore.ops.ScatterNd

Refer to mindspore.ops.scatter_nd() for more details.

Ascend GPU CPU

None

mindspore.ops.ScatterNdDiv

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

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.ScatterNdMax

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

Ascend GPU CPU

None

mindspore.ops.ScatterNdMin

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

Ascend GPU CPU

None

mindspore.ops.ScatterNdMul

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

GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.SearchSorted

Returns the indices correspond to the positions where the given numbers in values should be inserted into sorted_sequence so that the order of the sequence is maintained.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Select

Refer to mindspore.ops.select() for more details.

Ascend GPU CPU

None

mindspore.ops.Shape

Returns the shape of the input tensor.

Ascend GPU CPU

None

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

None

mindspore.ops.Slice

Slices a tensor in the specified shape.

Ascend GPU CPU

None

mindspore.ops.Sort

Sorts the elements of the input tensor along the given dimension in the specified order.

Ascend GPU CPU

Currently, the data types of float16, uint8, int8, int16, int32, int64 are well supported. If use float32, it may cause loss of accuracy.

mindspore.ops.SpaceToBatchND

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

Ascend GPU CPU

None

mindspore.ops.SpaceToDepth

Rearrange blocks of spatial data into depth.

Ascend GPU CPU

None

mindspore.ops.SparseGatherV2

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

Ascend GPU

None

mindspore.ops.Split

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

Ascend GPU CPU

None

mindspore.ops.Squeeze

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

Ascend GPU CPU

None

mindspore.ops.Stack

Stacks a list of tensors in specified axis.

Ascend GPU CPU

None

mindspore.ops.StridedSlice

Refer to mindspore.ops.strided_slice() for more details.

Ascend GPU CPU

None

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

None

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

None

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

None

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

None

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

None

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

None

mindspore.ops.TensorScatterUpdate

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

Ascend GPU CPU

None

mindspore.ops.TensorShape

Returns the shape of the input tensor.

Ascend GPU CPU

None

mindspore.ops.Tile

Replicates an input tensor with given multiple times.

Ascend GPU CPU

None

mindspore.ops.Trace

Refer to mindspore.ops.trace() for more details.

Ascend GPU CPU

None

mindspore.ops.Transpose

Refer to mindspore.ops.transpose() for more details.

Ascend GPU CPU

None

mindspore.ops.Tril

Refer to mindspore.ops.tril() for more details.

Ascend GPU CPU

None

mindspore.ops.TrilIndices

Calculates the indices of the lower triangular elements in a row * col matrix and returns them as a 2-by-N Tensor.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.Triu

Refer to mindspore.ops.triu() for more details.

Ascend GPU CPU

None

mindspore.ops.TriuIndices

Calculates the indices of the upper triangular elements in a row * col matrix and returns them as a 2-by-N Tensor.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

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

None

mindspore.ops.UniqueConsecutive

Returns the elements that are unique in each consecutive group of equivalent elements in the input tensor.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.UniqueWithPad

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

Ascend GPU CPU

None

mindspore.ops.UnsortedSegmentMax

Computes the maximum along segments of a tensor.

Ascend GPU CPU

None

mindspore.ops.UnsortedSegmentMin

Computes the minimum of a tensor along segments.

Ascend GPU CPU

None

mindspore.ops.UnsortedSegmentProd

Computes the product of a tensor along segments.

Ascend GPU CPU

None

mindspore.ops.UnsortedSegmentSum

Refer to mindspore.ops.unsorted_segment_sum() for more details.

Ascend GPU CPU

None

mindspore.ops.Unstack

Unstacks tensor in specified axis, this is the opposite of ops.Stack.

Ascend GPU CPU

None

Type Conversion

API Name

Description

Supported Platforms

Warning

mindspore.ops.ScalarCast

'ops.ScalarCast' is deprecated from version 2.3 and will be removed in a future version, please use int(x) or float(x) instead.

Deprecated

None

mindspore.ops.ScalarToTensor

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

Ascend GPU CPU

None

mindspore.ops.TupleToArray

Converts a tuple to a tensor.

Ascend GPU CPU

None

Parameter Operation Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.Assign

Refer to mindspore.ops.assign() for more details.

Ascend GPU CPU

None

mindspore.ops.AssignAdd

Refer to mindspore.ops.assign_add() for more details.

Ascend GPU CPU

None

mindspore.ops.AssignSub

Updates a Parameter by subtracting a value from it.

Ascend GPU CPU

None

mindspore.ops.ScatterAdd

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

Ascend GPU CPU

None

mindspore.ops.ScatterDiv

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

Ascend GPU CPU

None

mindspore.ops.ScatterMax

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

Ascend GPU CPU

None

mindspore.ops.ScatterMin

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

Ascend GPU CPU

None

mindspore.ops.ScatterMul

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

Ascend GPU CPU

None

mindspore.ops.ScatterNdAdd

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

Ascend GPU CPU

None

mindspore.ops.ScatterNdSub

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

Ascend GPU CPU

None

mindspore.ops.ScatterNdUpdate

Updates tensor values by using input indices and value.

Ascend GPU CPU

None

mindspore.ops.ScatterNonAliasingAdd

Please use TensorScatterAdd instead.

Deprecated

None

mindspore.ops.ScatterSub

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

Ascend GPU CPU

None

mindspore.ops.ScatterUpdate

Updates tensor values by using input indices and value.

Ascend GPU CPU

None

Data Operation Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.GetNext

Returns the next element in the dataset queue.

Ascend GPU

None

Communication Operator

Distributed training involves communication operations for data transfer. For more details, refer to Distributed Set Communication Primitives .

Note that the APIs in the following list need to preset communication environment variables. For the Ascend devices, users need to prepare the rank table, set rank_id and device_id. Please see the rank table Startup for more details. For the GPU device, users need to prepare the host file and mpi, please see the mpirun Startup . For the CPU device, users need to write a dynamic cluster startup script, please see the Dynamic Cluster Startup .

API Name

Description

Supported Platforms

Warning

mindspore.ops.AllGather

Gathers tensors from the specified communication group.

Ascend GPU

None

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

None

mindspore.ops.AlltoAll

AlltoAll is a collective operation.

Ascend

None

mindspore.ops.Broadcast

Broadcasts the tensor to the whole group.

Ascend GPU

None

mindspore.ops.NeighborExchangeV2

NeighborExchangeV2 is a collective communication operation.

Ascend

None

mindspore.ops.ReduceOp

Operation options for reducing tensors.

Ascend GPU

None

mindspore.ops.ReduceScatter

Reduces and scatters tensors from the specified communication group.

Ascend GPU

None

Debugging Operator

API Name

Description

Supported Platforms

Warning

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

None

mindspore.ops.ImageSummary

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

Ascend GPU CPU

None

mindspore.ops.ScalarSummary

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

Ascend GPU CPU

None

mindspore.ops.TensorSummary

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

Ascend GPU CPU

None

mindspore.ops.TensorDump

Save the Tensor as an npy file in numpy format.

Ascend

If a large amount of data is stored within a short period, it may lead to memory overflow on the device side. Consider slicing the data to reduce the data scale. Since data saving is processed asynchronously, when the amount of data is too large or the main process exits too quickly, data loss may occur. You need to actively control the destruction time of the main process, such as using sleep.

mindspore.ops.Print

Print the inputs to stdout.

Ascend GPU CPU

None

mindspore.ops.NPUAllocFloatStatus

Allocates a flag to store the overflow status.

Ascend

None

mindspore.ops.NPUClearFloatStatus

Clears the flag which stores the overflow status.

Ascend

None

mindspore.ops.NPUGetFloatStatus

mindspore.ops.NPUGetFloatStatus updates the flag which is the output tensor of mindspore.ops.NPUAllocFloatStatus with the latest overflow status.

Ascend

None

Sparse Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.SparseTensorDenseMatmul

Multiplies sparse matrix A by dense matrix B.

GPU CPU

None

mindspore.ops.SparseToDense

Converts a sparse representation into a dense tensor.

CPU

None

Frame Operators

API Name

Description

Supported Platforms

Warning

mindspore.ops.Depend

Depend is used for processing dependency operations.

Ascend GPU CPU

None

mindspore.ops.GradOperation

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

Ascend GPU CPU

None

mindspore.ops.HookBackward

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

Ascend GPU CPU

None

mindspore.ops.HyperMap

Hypermap will apply the set operation to input sequences.

Ascend GPU CPU

None

mindspore.ops.InsertGradientOf

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

Ascend GPU CPU

None

mindspore.ops.Map

Map will apply the set operation on input sequences.

Ascend GPU CPU

None

mindspore.ops.MultitypeFuncGraph

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

Ascend GPU CPU

None

mindspore.ops.Partial

Makes a partial function instance.

Ascend GPU CPU

None

Operator Information Registration

mindspore.ops.AiCPURegOp

Class for AiCPU operator information registration.

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

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

Warning

mindspore.ops.Custom

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

GPU CPU

This is an experimental API that is subject to change.

mindspore.ops.custom_info_register

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

Ascend GPU CPU

None

mindspore.ops.kernel

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

Ascend GPU CPU

None

Spectral Operator

API Name

Description

Supported Platforms

Warning

mindspore.ops.BartlettWindow

Bartlett window function.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.

mindspore.ops.BlackmanWindow

Blackman window function.

Ascend GPU CPU

This is an experimental API that is subject to change or deletion.