mindspore.ops

Neural Network Layer Functions

Neural Network

API Name

Description

Supported Platforms

mindspore.ops.adaptive_avg_pool2d

This operator applies a 2D adaptive average pooling to an input signal composed of multiple input planes.

GPU

mindspore.ops.adaptive_avg_pool3d

This operator applies a 3D adaptive average pooling to an input signal composed of multiple input planes.

GPU CPU

mindspore.ops.adaptive_max_pool2d

This operator applies a 2D adaptive max pooling to an input signal composed of multiple input planes.

Ascend GPU CPU

mindspore.ops.adaptive_max_pool3d

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

GPU CPU

mindspore.ops.avg_pool2d

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

Ascend GPU CPU

mindspore.ops.avg_pool3d

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

Ascend CPU

mindspore.ops.batch_norm

Batch Normalization for input data and updated parameters.

Ascend CPU GPU

mindspore.ops.bias_add

Returns the sum of the input_x and the bias Tensor.

Ascend GPU CPU

mindspore.ops.conv2d

Applies a 2D convolution over an input tensor.

Ascend GPU CPU

mindspore.ops.conv3d

Applies a 3D convolution over an input tensor.

Ascend GPU CPU

mindspore.ops.ctc_greedy_decoder

Performs greedy decoding on the logits given in inputs.

Ascend CPU

mindspore.ops.deformable_conv2d

Given 4D tensor inputs x, weight and offsets, compute a 2D deformable convolution.

Ascend GPU CPU

mindspore.ops.dropout

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

Ascend GPU CPU

mindspore.ops.dropout1d

During training, randomly zeroes some channels of the input tensor with probability p from a Bernoulli distribution(For a 3-dimensional tensor with a shape of \(NCL\), the channel feature map refers to a 1-dimensional feature map with the shape of \(L\)).

Ascend GPU CPU

mindspore.ops.dropout2d

During training, randomly zeroes some channels of the input tensor with probability p 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 p 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.flatten

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

Ascend GPU CPU

mindspore.ops.unfold

Extracts sliding local blocks from a batched input tensor.

Ascend CPU

mindspore.ops.fold

Combines an array of sliding local blocks into a large containing tensor.

CPU GPU

mindspore.ops.fractional_max_pool2d

Applies a 2D fractional max pooling to an input signal.

CPU

mindspore.ops.fractional_max_pool3d

This operator applies a 3D fractional max pooling over an input signal.

GPU CPU

mindspore.ops.interpolate

Using the interpolate method specified by mode resize the input tensor x.

Ascend CPU GPU

mindspore.ops.lp_pool1d

Applies a 1D power lp pooling over an input signal composed of several input planes.

Ascend GPU CPU

mindspore.ops.lp_pool2d

Applies a 2D power lp pooling over an input signal composed of several input planes.

Ascend GPU CPU

mindspore.ops.lrn

Local Response Normalization.

Ascend GPU CPU

mindspore.ops.max_pool3d

Performs a 3D max pooling on the input Tensor.

GPU

mindspore.ops.max_unpool1d

Computes a partial inverse of maxpool1d.

GPU CPU

mindspore.ops.max_unpool2d

Computes a partial inverse of maxpool2d.

GPU CPU

mindspore.ops.max_unpool3d

Computes a partial inverse of maxpool3d.

GPU CPU

Loss Functions

API Name

Description

Supported Platforms

mindspore.ops.binary_cross_entropy

Computes the binary cross entropy between predictive value logits and target value labels.

Ascend GPU CPU

mindspore.ops.binary_cross_entropy_with_logits

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

The cross entropy loss between input and target.

Ascend GPU CPU

mindspore.ops.gaussian_nll_loss

Gaussian negative log likelihood loss.

Ascend GPU CPU

mindspore.ops.hinge_embedding_loss

Hinge Embedding Loss.

Ascend GPU CPU

mindspore.ops.kl_div

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

Ascend GPU CPU

mindspore.ops.margin_ranking_loss

MarginRankingLoss creates a criterion that measures the loss.

Ascend GPU CPU

mindspore.ops.multi_label_margin_loss

Hinge loss for optimizing a multi-label classification.

Ascend GPU

mindspore.ops.nll_loss

Gets the negative log likelihood loss between inputs and target.

Ascend GPU CPU

mindspore.ops.smooth_l1_loss

Computes smooth L1 loss, a robust L1 loss.

Ascend GPU CPU

Activation Functions

API Name

Description

Supported Platforms

mindspore.ops.elu

Exponential Linear Unit activation function.

Ascend GPU CPU

mindspore.ops.fast_gelu

Fast Gaussian Error Linear Units activation function.

Ascend GPU CPU

mindspore.ops.gelu

Gaussian Error Linear Units activation function.

Ascend CPU GPU

mindspore.ops.glu

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

Ascend GPU CPU

mindspore.ops.gumbel_softmax

Returns the samples from the Gumbel-Softmax distribution and optionally discretizes.

Ascend GPU CPU

mindspore.ops.hardshrink

Hard Shrink activation function.

Ascend GPU CPU

mindspore.ops.hardswish

Applies hswish-type activation element-wise.

Ascend GPU CPU

mindspore.ops.log_softmax

Applies the Log Softmax function to the input tensor on the specified axis.

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

Computes Sigmoid of input element-wise.

Ascend GPU CPU

mindspore.ops.softsign

Softsign activation function.

Ascend GPU CPU

mindspore.ops.soft_shrink

Applies the SoftShrink function element-wise.

Ascend CPU GPU

mindspore.ops.softmax

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

Ascend GPU CPU

mindspore.ops.tanh

Computes hyperbolic tangent of input element-wise.

Ascend GPU CPU

Sampling Functions

API Name

Description

Supported Platforms

mindspore.ops.choice_with_mask

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

Ascend GPU CPU

mindspore.ops.random_categorical

Generates random samples from a given categorical distribution tensor.

Ascend GPU CPU

mindspore.ops.log_uniform_candidate_sampler

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

Ascend CPU

mindspore.ops.uniform_candidate_sampler

Uniform candidate sampler.

Ascend GPU CPU

Distance Functions

API Name

Description

Supported Platforms

mindspore.ops.cdist

Computes p-norm distance between each pair of row vectors of two input Tensors.

Ascend GPU CPU

mindspore.ops.pdist

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

CPU

Element-by-Element Operations

API Name

Description

Supported Platforms

mindspore.ops.abs

Returns absolute value of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.absolute

Alias for mindspore.ops.abs() .

Ascend GPU CPU

mindspore.ops.accumulate_n

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

Executes the outer-product of vec1 and vec2 and adds it to the matrix x.

Ascend GPU CPU

mindspore.ops.angle

Returns the element-wise argument of a complex tensor.

CPU

mindspore.ops.arccos

Alias for mindspore.ops.acos() .

Ascend GPU CPU

mindspore.ops.arccosh

For details, please refer to mindspore.ops.acosh().

Ascend GPU CPU

mindspore.ops.arcsin

For details, please refer to mindspore.ops.asin().

Ascend GPU CPU

mindspore.ops.arctan

For details, please refer to mindspore.ops.atan().

Ascend GPU CPU

mindspore.ops.arctan2

For details, please refer to mindspore.ops.atan2().

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

Computes the Bessel i0 function of x element-wise.

GPU CPU

mindspore.ops.bessel_i0e

Computes the Bessel i0e function of x element-wise.

Ascend GPU CPU

mindspore.ops.bessel_i1

Computes the Bessel i1 function of x element-wise.

GPU CPU

mindspore.ops.bessel_i1e

Computes the Bessel i1e function of x element-wise.

GPU CPU

mindspore.ops.bessel_j0

Computes the Bessel j0 function of x element-wise.

GPU CPU

mindspore.ops.bessel_j1

Computes the Bessel j1 function of x element-wise.

GPU CPU

mindspore.ops.bessel_k0

Computes the Bessel k0 function of x element-wise.

GPU CPU

mindspore.ops.bessel_k0e

Computes the Bessel k0e function of x element-wise.

GPU CPU

mindspore.ops.bessel_k1

Computes the Bessel k1 function of x element-wise.

GPU CPU

mindspore.ops.bessel_k1e

Computes the Bessel k1e function of x element-wise.

GPU CPU

mindspore.ops.bessel_y0

Computes the Bessel y0 function of x element-wise.

GPU CPU

mindspore.ops.bessel_y1

Computes the Bessel y1 function of x element-wise.

GPU CPU

mindspore.ops.bitwise_and

Returns bitwise and of two tensors element-wise.

Ascend GPU CPU

mindspore.ops.bitwise_or

Returns bitwise or of two tensors element-wise.

Ascend GPU CPU

mindspore.ops.bitwise_xor

Returns bitwise xor of two tensors element-wise.

Ascend GPU CPU

mindspore.ops.ceil

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

Ascend GPU CPU

mindspore.ops.copysign

Create a new floating-point tensor with the magnitude of x and the sign of other, element-wise.

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

Calculates a new tensor with each of the elements of x converted from angles in degrees to radians.

Ascend GPU CPU

mindspore.ops.div

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

Ascend CPU GPU

mindspore.ops.divide

Alias for mindspore.ops.div() .

Ascend GPU CPU

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

mindspore.ops.exp

Returns exponential of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.expm1

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

Ascend GPU CPU

mindspore.ops.floor

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

Ascend GPU CPU

mindspore.ops.floor_div

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

Ascend GPU CPU

mindspore.ops.floor_mod

Computes the remainder of division element-wise.

Ascend GPU CPU

mindspore.ops.heaviside

Computes the Heaviside step function for each element in input.

GPU CPU

mindspore.ops.hypot

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

CPU

mindspore.ops.i0

Alias for mindspore.ops.bessel_i0() .

Ascend GPU CPU

mindspore.ops.igamma

Calculates lower regularized incomplete Gamma function.

Ascend CPU GPU

mindspore.ops.igammac

Calculates upper regularized incomplete Gamma function.

Ascend CPU GPU

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

Computes least common multiplier of input tensors element-wise.

GPU CPU

mindspore.ops.ldexp

Multiplies input by \(2^{other}\) .

Ascend GPU CPU

mindspore.ops.lerp

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

Ascend GPU CPU

mindspore.ops.log

Returns the natural logarithm of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.log10

Returns a new tensor with the logarithm to the base 10 of the elements of input.

Ascend GPU CPU

mindspore.ops.log1p

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

Ascend GPU CPU

mindspore.ops.log2

Returns a new tensor with the logarithm to the base 2 of the elements of input.

Ascend GPU CPU

mindspore.ops.logaddexp

Computes the logarithm of the sum of exponentiations of the inputs.

Ascend GPU CPU

mindspore.ops.logaddexp2

Computes the logarithm of the sum of exponentiations in base of 2 of the inputs.

Ascend GPU CPU

mindspore.ops.logical_and

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

Ascend GPU CPU

mindspore.ops.logical_not

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

Ascend GPU CPU

mindspore.ops.logical_or

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

Ascend GPU CPU

mindspore.ops.logical_xor

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

CPU

mindspore.ops.logit

Calculate the logit of a tensor element-wise.

GPU CPU

mindspore.ops.mul

Multiplies two tensors element-wise.

Ascend GPU CPU

mindspore.ops.multiply

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

Ascend GPU CPU

mindspore.ops.neg

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

Ascend GPU CPU

mindspore.ops.negative

Alias for mindspore.ops.neg() .

Ascend GPU CPU

mindspore.ops.positive

Return self Tensor.

Ascend GPU CPU

mindspore.ops.pow

Calculates the y power of each element in x.

Ascend GPU CPU

mindspore.ops.rad2deg

Returns a new tensor with each of the elements of x converted from angles in radians to degrees.

Ascend GPU CPU

mindspore.ops.remainder

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

Ascend GPU CPU

mindspore.ops.roll

Rolls the elements of a tensor along an axis.

Ascend GPU

mindspore.ops.round

Returns half to even of a 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 sqrt of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.square

Returns square 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.subtract

Performs the element-wise subtraction of input tensors.

Ascend GPU CPU

mindspore.ops.tan

Computes tangent of x element-wise.

Ascend CPU GPU

mindspore.ops.true_divide

Alias for mindspore.ops.div() with \(rounding\_mode=None\).

Ascend GPU CPU

mindspore.ops.trunc

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

Ascend GPU CPU

mindspore.ops.truncate_div

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

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 Functions

API Name

Description

Supported Platforms

mindspore.ops.amax

Reduces all dimensions of a tensor by returning the maximum value in x, by default.

Ascend GPU CPU

mindspore.ops.amin

Reduces all dimensions of a tensor by returning the minimum value in x, by default.

Ascend GPU CPU

mindspore.ops.argmax

Return the indices of the maximum values of a tensor across a dimension.

Ascend GPU CPU

mindspore.ops.argmin

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

Ascend GPU CPU

mindspore.ops.cummax

Returns a tuple (values,indices) where 'values' is the cumulative maximum value of input Tensor x along the dimension axis, and indices is the index location of each maximum value.

GPU CPU

mindspore.ops.cummin

Returns a tuple (values,indices) where 'values' is the cumulative minimum value of input Tensor x along the dimension axis, and indices is the index location of each minimum value.

Ascend GPU CPU

mindspore.ops.cumsum

Computes the cumulative sum of input Tensor along axis.

Ascend GPU CPU

mindspore.ops.logsumexp

Reduces a dimension of a tensor by calculating exponential for all elements in the dimension, then calculate logarithm of the sum.

Ascend GPU CPU

mindspore.ops.max

Calculates the maximum value along with the given axis for the input tensor.

Ascend GPU CPU

mindspore.ops.mean

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

Ascend GPU CPU

mindspore.ops.median

Computes the median and indices of input tensor.

GPU CPU

mindspore.ops.min

Calculates the minimum value along with the given axis for the input tensor.

Ascend GPU CPU

mindspore.ops.norm

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

Ascend GPU CPU

mindspore.ops.prod

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

Ascend GPU CPU

mindspore.ops.std

Returns the standard-deviation and mean of each row of the input tensor by default, or it can calculate them in specified dimension axis.

Ascend CPU

Comparison Functions

API Name

Description

Supported Platforms

mindspore.ops.approximate_equal

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

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

Ascend GPU CPU

mindspore.ops.greater

Computes the boolean value of \(input > other\) element-wise.

Ascend CPU GPU

mindspore.ops.greater_equal

Computes the boolean value of \(input >= other\) element-wise.

Ascend CPU GPU

mindspore.ops.gt

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

Ascend GPU CPU

mindspore.ops.intopk

Determines whether the targets are in the top k predictions.

Ascend GPU CPU

mindspore.ops.isclose

Returns a new Tensor with boolean elements representing if each element of x1 is “close” to the corresponding element of x2.

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

Judge whether the data type of x is a floating point data type i.e., one of mindspore.flot64, mindspore.float32, mindspore.float16.

Ascend GPU CPU

mindspore.ops.le

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

Ascend GPU CPU

mindspore.ops.less

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

Ascend GPU CPU

mindspore.ops.less_equal

Computes the boolean value of \(input\_x <= other\) 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.ne

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

Ascend GPU CPU

mindspore.ops.top_k

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

Ascend GPU CPU

Linear Algebraic Functions

API Name

Description

Supported Platforms

mindspore.ops.addbmm

Applies batch matrix multiplication to batch1 and batch2, with a reduced add step.

Ascend GPU CPU

mindspore.ops.addmm

Multiplies matrix mat1 and matrix mat2.

Ascend GPU CPU

mindspore.ops.adjoint

Returns a view of the tensor conjugated and with the last two dimensions transposed.

Ascend GPU CPU

mindspore.ops.baddbmm

Performs a batch matrix-matrix product of matrices in batch1 and batch2.

Ascend GPU CPU

mindspore.ops.bmm

Computes matrix multiplication between two tensors by batch.

Ascend GPU CPU

mindspore.ops.batch_dot

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

Ascend GPU CPU

mindspore.ops.cholesky

Computes the Cholesky decomposition of a symmetric positive-definite matrix \(A\) or for batches of symmetric positive-definite matrices.

Ascend CPU

mindspore.ops.cholesky_inverse

Returns the inverse of the positive definite matrix using cholesky matrix factorization.

GPU CPU

mindspore.ops.cross

Returns the cross product of vectors in dimension dim of input input and other.

CPU

mindspore.ops.dot

Computation a dot product between samples in two tensors.

Ascend GPU CPU

mindspore.ops.ger

Ger product of x1 and x2.

Ascend GPU CPU

mindspore.ops.matmul

Returns the matrix product of two tensors.

Ascend GPU CPU

mindspore.ops.matrix_band_part

Copy a tensor setting everything outside a central band in each innermost matrix to zero.

GPU CPU

mindspore.ops.matrix_diag

Returns a Tensor with the contents in x as k[0]-th to k[1]-th diagonals of a matrix, with everything else padded with padding_value.

Ascend GPU CPU

mindspore.ops.matrix_diag_part

Returns the diagonal part of input tensor.

Ascend GPU CPU

mindspore.ops.matrix_exp

Computes the matrix exponential of a square matrix.

CPU

mindspore.ops.matrix_set_diag

Returns a batched matrix tensor with new batched diagonal values.

GPU CPU

mindspore.ops.matrix_solve

Solves systems of linear equations.

GPU CPU

mindspore.ops.pinv

Computes the (Moore-Penrose) pseudo-inverse of a matrix.

CPU

mindspore.ops.renorm

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

Ascend CPU GPU

mindspore.ops.svd

Computes the singular value decompositions of one or more matrices.

GPU CPU

mindspore.ops.tensor_dot

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

Ascend GPU CPU

Spectral Functions

API Name

Description

Supported Platforms

mindspore.ops.bartlett_window

Bartlett window function.

GPU CPU

mindspore.ops.blackman_window

Blackman window function.

GPU CPU

Tensor Operation Functions

Tensor Building

API Name

Description

Supported Platforms

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

Computes a one-hot tensor.

Ascend GPU CPU

mindspore.ops.ones

Creates a tensor filled with value ones.

Ascend GPU CPU

mindspore.ops.ones_like

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

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

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

Randomly Generating Functions

API Name

Description

Supported Platforms

mindspore.ops.bernoulli

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

GPU

mindspore.ops.gamma

Generates random numbers according to the Gamma random number distribution.

Ascend

mindspore.ops.laplace

Generates random numbers according to the Laplace random number distribution.

Ascend

mindspore.ops.multinomial

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

GPU

mindspore.ops.normal

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

Ascend GPU CPU

mindspore.ops.random_poisson

Generates random number Tensor with shape shape according to a Poisson distribution with mean rate.

CPU

mindspore.ops.random_gamma

Outputs random values from the Gamma distribution(s) described by alpha.

CPU

mindspore.ops.standard_laplace

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

Ascend GPU CPU

mindspore.ops.standard_normal

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

Ascend GPU CPU

mindspore.ops.uniform

Generates random numbers according to the Uniform random number distribution.

Ascend GPU CPU

Array Operation

API Name

Description

Supported Platforms

mindspore.ops.batch_to_space_nd

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

Ascend GPU CPU

mindspore.ops.broadcast_to

Broadcasts input tensor to a given shape.

Ascend GPU CPU

mindspore.ops.col2im

Combines an array of sliding local blocks into a large containing tensor.

GPU

mindspore.ops.concat

Connect input tensors along with the given axis.

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

Count number of nonzero elements across axis of input tensor

Ascend GPU CPU

mindspore.ops.diag

Constructs a diagonal tensor with a given diagonal values.

Ascend GPU

mindspore.ops.diagonal

Returns specified diagonals of input.

Ascend GPU CPU

mindspore.ops.expand

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

Ascend CPU

mindspore.ops.expand_dims

Adds an additional dimension to input_x at the given axis.

Ascend GPU CPU

mindspore.ops.flip

Reverses the order of elements in a tensor along the given axis.

GPU CPU

mindspore.ops.fliplr

Flips the entries in each row in the left/right direction.

GPU CPU

mindspore.ops.flipud

Flips the entries in each column in the up/down direction.

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

Gathers elements along an axis specified by dim.

Ascend GPU CPU

mindspore.ops.gather_elements

Gathers elements along an axis specified by dim.

Ascend GPU CPU

mindspore.ops.gather_nd

Gathers slices from a tensor by indices.

Ascend GPU CPU

mindspore.ops.index_add

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

Ascend GPU CPU

mindspore.ops.index_fill

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.

GPU

mindspore.ops.inplace_add

Adds v into specified rows of x.

Ascend CPU

mindspore.ops.inplace_sub

Subtracts v into specified rows of x.

Ascend CPU

mindspore.ops.inplace_update

Updates specified rows with values in v.

Ascend GPU CPU

mindspore.ops.masked_fill

Fills elements of Tensor with value where mask is True.

Ascend GPU CPU

mindspore.ops.masked_select

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

Ascend GPU CPU

mindspore.ops.meshgrid

Generates coordinate matrices from given coordinate tensors.

Ascend CPU GPU

mindspore.ops.narrow

Returns a narrowed tensor from input tensor, and the dimension axis is input from start to start + length.

Ascend GPU CPU

mindspore.ops.nonzero

Return a Tensor of the positions of all non-zero values.

Ascend GPU CPU

mindspore.ops.numel

Returns a Scalar of type int that represents the total number of elements in the Tensor.

Ascend GPU CPU

mindspore.ops.permute

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

Ascend GPU CPU

mindspore.ops.population_count

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

Ascend GPU CPU

mindspore.ops.rank

Returns the rank of a tensor.

Ascend GPU CPU

mindspore.ops.repeat_elements

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

Ascend GPU CPU

mindspore.ops.repeat_interleave

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

Ascend GPU CPU

mindspore.ops.reshape

Rearranges the input Tensor based on the given shape.

Ascend GPU CPU

mindspore.ops.reverse

Reverses specific dimensions of a tensor.

Ascend GPU CPU

mindspore.ops.reverse_sequence

Reverses variable length slices.

Ascend GPU CPU

mindspore.ops.scatter_nd

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

Ascend GPU CPU

mindspore.ops.select

The conditional tensor determines whether the corresponding element in the output must be selected from \(x\) (if true) or \(y\) (if false) based on the value of each element.

Ascend GPU CPU

mindspore.ops.sequence_mask

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

GPU

mindspore.ops.shape

Returns the shape of the input tensor.

Ascend GPU CPU

mindspore.ops.shuffle

Randomly shuffles a Tensor along its first dimension.

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

Divides a tensor's spatial dimensions into blocks and combines the block sizes with the original batch.

Ascend GPU CPU

mindspore.ops.sparse_segment_mean

Computes a Tensor such that \(output_i = \frac{\sum_j x_{indices[j]}}{N}\) where mean is over \(j\) such that \(segment\_ids[j] == i\) and \(N\) is the total number of values summed.

GPU CPU

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

Extracts a strided slice of a Tensor based on begin/end index and strides.

Ascend GPU CPU

mindspore.ops.tensor_scatter_add

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

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

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 largest one to create a new tensor.

GPU CPU

mindspore.ops.tensor_scatter_min

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

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

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

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

Ascend GPU CPU

mindspore.ops.tile

Replicates an input tensor with given multiples times.

Ascend GPU CPU

mindspore.ops.transpose

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

Ascend GPU CPU

mindspore.ops.unbind

Removes a tensor dimension in specified axis.

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

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

Ascend GPU

mindspore.ops.unique_with_pad

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

Ascend GPU CPU

mindspore.ops.unsorted_segment_max

Computes the maximum along segments of a tensor.

Ascend GPU CPU

mindspore.ops.unsorted_segment_min

Computes the minimum of a tensor along segments.

Ascend GPU CPU

mindspore.ops.unsorted_segment_prod

Computes the product of a tensor along segments.

Ascend GPU CPU

mindspore.ops.unsorted_segment_sum

Computes the sum of a tensor along segments.

Ascend GPU CPU

mindspore.ops.unsqueeze

Adds an additional dimension to input_x at the given dim.

Ascend GPU CPU

mindspore.ops.unstack

Unstacks tensor in specified axis.

Ascend GPU CPU

mindspore.ops.cumprod

Computes the cumulative product of the input tensor along dimension dim.

Ascend CPU GPU

Type Conversion

API Name

Description

Supported Platforms

mindspore.ops.scalar_cast

Casts the input scalar to another type.

Ascend GPU CPU

mindspore.ops.scalar_to_tensor

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

Ascend GPU CPU

mindspore.ops.tuple_to_array

Converts a tuple to a tensor.

Ascend GPU CPU

Sparse Functions

API Name

Description

Supported Platforms

mindspore.ops.dense_to_sparse_coo

Convert a Tensor to COOTensor.

GPU

mindspore.ops.dense_to_sparse_csr

Convert a Tensor to CSRTensor.

GPU

mindspore.ops.csr_to_coo

Converts a CSRTensor to COOTensor.

Ascend GPU CPU

COO Functions

API Name

Description

Supported Platforms

mindspore.ops.coo_abs

Returns coo_absolute value of a COOTensor element-wise.

Ascend GPU CPU

mindspore.ops.coo_acos

Computes arccosine of input coo_tensors element-wise.

Ascend GPU CPU

mindspore.ops.coo_acosh

Computes inverse hyperbolic cosine of the inputs element-wise.

Ascend GPU CPU

mindspore.ops.coo_asin

Computes arcsine of input coo_tensors element-wise.

Ascend GPU CPU

mindspore.ops.coo_asinh

Computes inverse hyperbolic sine of the input element-wise.

Ascend GPU CPU

mindspore.ops.coo_atan

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

Ascend GPU CPU

mindspore.ops.coo_atanh

Computes inverse hyperbolic tangent of the input element-wise.

Ascend GPU CPU

mindspore.ops.coo_ceil

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

Ascend GPU CPU

mindspore.ops.coo_cos

Computes cosine of input element-wise.

Ascend GPU CPU

mindspore.ops.coo_cosh

Computes hyperbolic cosine of input element-wise.

Ascend GPU CPU

mindspore.ops.coo_exp

Returns coo_exponential of a COOTensor element-wise.

Ascend GPU CPU

mindspore.ops.coo_expm1

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

Ascend GPU CPU

mindspore.ops.coo_floor

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

Ascend GPU CPU

mindspore.ops.coo_inv

Computes Reciprocal of input COOTensor element-wise.

Ascend GPU CPU

mindspore.ops.coo_isfinite

Determines which elements are finite for each position.

Ascend GPU CPU

mindspore.ops.coo_isinf

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

CPU GPU

mindspore.ops.coo_isnan

Determines which elements are NaN for each position.

Ascend GPU CPU

mindspore.ops.coo_log

Returns the natural logarithm of a COOTensor element-wise.

Ascend GPU CPU

mindspore.ops.coo_log1p

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

Ascend GPU CPU

mindspore.ops.coo_neg

Returns a COOTensor with coo_negative values of the input COOTensor element-wise.

Ascend GPU CPU

mindspore.ops.coo_relu

Computes ReLU (Rectified Linear Unit activation function) of input coo_tensors element-wise.

Ascend GPU CPU

mindspore.ops.coo_relu6

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

Ascend GPU CPU

mindspore.ops.coo_round

Returns half to even of a COOTensor element-wise.

Ascend GPU CPU

mindspore.ops.coo_sigmoid

Sigmoid activation function.

Ascend GPU CPU

mindspore.ops.coo_sin

Computes sine of the input element-wise.

Ascend GPU CPU

mindspore.ops.coo_sinh

Computes hyperbolic sine of the input element-wise.

Ascend GPU CPU

mindspore.ops.coo_softsign

Softsign activation function.

Ascend GPU CPU

mindspore.ops.coo_sqrt

Returns sqrt of a COOTensor element-wise.

Ascend GPU CPU

mindspore.ops.coo_square

Returns square of a COOTensor element-wise.

Ascend GPU CPU

mindspore.ops.coo_tan

Computes tangent of x element-wise.

Ascend CPU GPU

mindspore.ops.coo_tanh

Computes hyperbolic tangent of input element-wise.

Ascend GPU CPU

mindspore.ops.sparse_add

Computes the sum of x1(COOTensor) and x2(COOTensor), and return a new COOTensor based on the computed result and thresh.

CPU GPU

CSR Functions

API Name

Description

Supported Platforms

mindspore.ops.csr_abs

Returns csr_absolute value of a CSRTensor element-wise.

Ascend GPU CPU

mindspore.ops.csr_acos

Computes arccosine of input csr_tensors element-wise.

Ascend GPU CPU

mindspore.ops.csr_acosh

Computes inverse hyperbolic cosine of the inputs element-wise.

Ascend GPU CPU

mindspore.ops.csr_add

Returns alpha * csr_a + beta * csr_b where both csr_a and csr_b are CSRTensor, alpha and beta are both Tensor.

GPU CPU

mindspore.ops.csr_asin

Computes arcsine of input csr_tensors element-wise.

Ascend GPU CPU

mindspore.ops.csr_asinh

Computes inverse hyperbolic sine of the input element-wise.

Ascend GPU CPU

mindspore.ops.csr_atan

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

Ascend GPU CPU

mindspore.ops.csr_atanh

Computes inverse hyperbolic tangent of the input element-wise.

Ascend GPU CPU

mindspore.ops.csr_ceil

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

Ascend GPU CPU

mindspore.ops.csr_cos

Computes cosine of input element-wise.

Ascend GPU CPU

mindspore.ops.csr_cosh

Computes hyperbolic cosine of input element-wise.

Ascend GPU CPU

mindspore.ops.csr_exp

Returns csr_exponential of a CSRTensor element-wise.

Ascend GPU CPU

mindspore.ops.csr_expm1

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

Ascend GPU CPU

mindspore.ops.csr_floor

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

Ascend GPU CPU

mindspore.ops.csr_inv

Computes Reciprocal of input CSRTensor element-wise.

Ascend GPU CPU

mindspore.ops.csr_isfinite

Determines which elements are finite for each position.

Ascend GPU CPU

mindspore.ops.csr_isinf

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

CPU GPU

mindspore.ops.csr_isnan

Determines which elements are NaN for each position.

Ascend GPU CPU

mindspore.ops.csr_log

Returns the natural logarithm of a CSRTensor element-wise.

Ascend GPU CPU

mindspore.ops.csr_log1p

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

Ascend GPU CPU

mindspore.ops.csr_neg

Returns a CSRTensor with csr_negative values of the input CSRTensor element-wise.

Ascend GPU CPU

mindspore.ops.csr_relu

Computes ReLU (Rectified Linear Unit activation function) of input csr_tensors element-wise.

Ascend GPU CPU

mindspore.ops.csr_relu6

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

Ascend GPU CPU

mindspore.ops.csr_round

Returns half to even of a CSRTensor element-wise.

Ascend GPU CPU

mindspore.ops.csr_sigmoid

Sigmoid activation function.

Ascend GPU CPU

mindspore.ops.csr_sin

Computes sine of the input element-wise.

Ascend GPU CPU

mindspore.ops.csr_sinh

Computes hyperbolic sine of the input element-wise.

Ascend GPU CPU

mindspore.ops.csr_softmax

Calculates the softmax of a CSRTensorMatrix.

GPU CPU

mindspore.ops.csr_softsign

Softsign activation function.

Ascend GPU CPU

mindspore.ops.csr_sqrt

Returns sqrt of a CSRTensor element-wise.

Ascend GPU CPU

mindspore.ops.csr_square

Returns square of a CSRTensor element-wise.

Ascend GPU CPU

mindspore.ops.csr_tan

Computes tangent of x element-wise.

Ascend CPU GPU

mindspore.ops.csr_tanh

Computes hyperbolic tangent of input element-wise.

Ascend GPU CPU

Gradient Clipping

API Name

Description

Supported Platforms

mindspore.ops.clip_by_global_norm

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

Ascend GPU CPU

mindspore.ops.clip_by_value

Clips tensor values to a specified min and max.

Ascend GPU CPU

Parameter Operation Functions

API Name

Description

Supported Platforms

mindspore.ops.assign

Assigns Parameter with a value.

Ascend GPU CPU

mindspore.ops.assign_add

Updates a Parameter by adding a value to it.

Ascend GPU CPU

mindspore.ops.assign_sub

Updates a Parameter by subtracting a value from it.

Ascend GPU CPU

mindspore.ops.scatter_add

Using given values to update tensor value through the add operation, along with the input indices.

Ascend GPU CPU

mindspore.ops.scatter_div

Using given values to update tensor value through the div operation, along with the input indices.

Ascend GPU CPU

mindspore.ops.scatter_max

Using given values to update tensor value through the max operation, along with the input indices.

Ascend CPU GPU

mindspore.ops.scatter_min

Using given values to update tensor value through the min operation, along with the input indices.

Ascend GPU CPU

mindspore.ops.scatter_mul

Using given values to update tensor value through the mul operation, along with the input indices.

Ascend GPU CPU

mindspore.ops.scatter_nd_add

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

Ascend GPU CPU

mindspore.ops.scatter_nd_div

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

GPU CPU

mindspore.ops.scatter_nd_max

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

Ascend GPU CPU

mindspore.ops.scatter_nd_min

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

Ascend GPU CPU

mindspore.ops.scatter_nd_mul

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

GPU CPU

mindspore.ops.scatter_nd_sub

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

Ascend GPU CPU

mindspore.ops.scatter_update

Updates tensor values by using input indices and value.

Ascend GPU CPU

Differential Functions

API Name

Description

Supported Platforms

mindspore.ops.derivative

This function is designed to calculate the higher order differentiation of given composite function.

Ascend GPU CPU

mindspore.ops.jet

This function is designed to calculate the higher order differentiation of given composite function.

Ascend GPU CPU

mindspore.ops.stop_gradient

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

Debugging Functions

API Name

Description

Supported Platforms

mindspore.ops.print_

Outputs the inputs to stdout.

Ascend GPU CPU

Image Functions

API Name

Description

Supported Platforms

mindspore.ops.bounding_box_decode

Decodes bounding boxes locations.

Ascend GPU CPU

mindspore.ops.bounding_box_encode

Encodes bounding boxes locations.

Ascend GPU CPU

mindspore.ops.check_valid

Checks bounding box.

Ascend GPU CPU

mindspore.ops.crop_and_resize

Extracts crops from the input image Tensor and resizes them.

Ascend GPU CPU

mindspore.ops.grid_sample

Given an input_x and a flow-field grid, computes the output using input_x values and pixel locations from grid.

Ascend GPU CPU

mindspore.ops.iou

Calculates intersection over union for boxes.

Ascend GPU CPU

mindspore.ops.pad

Pads the input tensor according to the padding.

Ascend GPU CPU

mindspore.ops.padding

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

Ascend GPU CPU

mindspore.ops.pixel_shuffle

Applies a pixel_shuffle operation over an input signal composed of several input planes.

Ascend GPU CPU

mindspore.ops.pixel_unshuffle

Applies a pixel_unshuffle operation over an input signal composed of several input planes.

Ascend GPU CPU