mindspore.ops

mindspore.ops provides a large number of function interfaces, including neural network functions, mathematical operation functions, Tensor operation functions, Parameter operation functions, differential functions and so on.

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

The module import method is as follows:

from mindspore import ops

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

Tensor Operation Functions

Tensor Creation

API Name

Description

Supported Platforms

mindspore.ops.eps

Create a tensor with the same data type and shape as input, and the element value is the minimum value that the corresponding data type can express.

Ascend GPU CPU

mindspore.ops.eye

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

Ascend GPU CPU

mindspore.ops.fill

Create a tensor filled with a specified value.

Ascend GPU CPU

mindspore.ops.full

Create a tensor filled with a specified value.

Ascend GPU CPU

mindspore.ops.full_like

Return a tensor of the same shape as input and filled with a specified value.

Ascend GPU CPU

mindspore.ops.linspace

Generate a one-dimensional tensor with steps elements, evenly distributed in the interval [start, end].

Ascend GPU CPU

mindspore.ops.logspace

Return a tensor with steps elements, evenly distributed in the interval [ \(base^{start}\) , \(base^{end}\)].

Ascend GPU CPU

mindspore.ops.move_to

Copy tensor to target device synchronously or asynchronously, default synchronously.

Ascend CPU

mindspore.ops.one_hot

Generate a new tensor, where the positions specified by indices are assigned on_value, and all other positions are assigned off_value.

Ascend GPU CPU

mindspore.ops.ones

Creates a tensor filled with value ones.

Ascend GPU CPU

mindspore.ops.ones_like

Return a tensor filled with 1, with the same size as input.

Ascend GPU CPU

mindspore.ops.arange

Returns a tensor with a step length of step in the interval [ start , end ).

Ascend GPU CPU

mindspore.ops.range

Returns a tensor with a step length of step in the interval [ start , end ).

GPU CPU

mindspore.ops.zeros

Creates a tensor filled with value zeros.

Ascend GPU CPU

mindspore.ops.zeros_like

Return a tensor filled with 0, with the same size as input .

Ascend GPU CPU

mindspore.ops.heaviside

Perform Heaviside step function element-wise.

Ascend GPU CPU

Randomly Generating Functions

API Name

Description

Supported Platforms

mindspore.ops.bernoulli

Generates Bernoulli random values (0 or 1).

GPU CPU

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

mindspore.ops.multinomial

Generate a tensor from a multinomial distribution.

Ascend GPU CPU

mindspore.ops.multinomial_with_replacement

Generate a tensor from a multinomial distribution.

CPU

mindspore.ops.rand

Return a new tensor that fills numbers from the uniform distribution over an interval \([0, 1)\) based on the given size and dtype.

Ascend GPU CPU

mindspore.ops.rand_like

Return a tensor with the same shape as input that is filled with random numbers from a uniform distribution on the interval \([0, 1)\).

Ascend GPU CPU

mindspore.ops.randint

Return a tensor whose elements are random integers in the range of [ low , high ) .

Ascend GPU CPU

mindspore.ops.randint_like

Returns a tensor with the same shape as input whose elements are random integers in the range of [ low , high ) .

Ascend GPU CPU

mindspore.ops.randn

Return a new tensor with given shape and dtype, filled with random numbers from the standard normal distribution.

Ascend GPU CPU

mindspore.ops.randn_like

Return a tensor with the same shape as input, filled with random numbers from the standard normal distribution.

Ascend GPU CPU

mindspore.ops.random_gamma

Generate random numbers from the Gamma distribution(s).

CPU

mindspore.ops.random_poisson

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

GPU CPU

mindspore.ops.randperm

Generates random permutation of integers from 0 to n-1.

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.

GPU CPU

Array Operation

API Name

Description

Supported Platforms

mindspore.ops.argwhere

Return a tensor of containing the positions of all non-zero elements in the input tensor.

Ascend GPU CPU

mindspore.ops.batch_to_space_nd

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

Ascend GPU CPU

mindspore.ops.bincount

Count the frequency of each value in the input tensor of non-negative ints.

Ascend GPU CPU

mindspore.ops.block_diag

Creates a block diagonal matrix from the provided tensor.

Ascend GPU CPU

mindspore.ops.broadcast_to

Broadcasts input tensor to a given shape.

Ascend GPU CPU

mindspore.ops.cat

Connect input tensors along with the given axis.

Ascend GPU CPU

mindspore.ops.channel_shuffle

Divide the channels in a tensor of shape \((*, C, H, W)\) into \(g\) groups and rearrange them as \((*, \frac{C}{g}, g, H*W)\), while retaining the original tensor shape in the final output.

Ascend CPU

mindspore.ops.chunk

Split the input tensor into multiple sub-tensors along the specified axis.

Ascend GPU CPU

mindspore.ops.column_stack

Creates a new tensor by horizontally stacking the tensors in tensors.

Ascend GPU CPU

mindspore.ops.concat

Alias for mindspore.ops.cat().

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

Counts the number of non-zero values in the input tensor along the given axis.

Ascend GPU CPU

mindspore.ops.deepcopy

Return a deepcopy of input tensor.

Ascend GPU CPU

mindspore.ops.diag

Return a tensor with the input as its diagonal elements and 0 elsewhere.

Ascend GPU CPU

mindspore.ops.diagflat

If input is a vector (1-D tensor), then returns a 2-D square tensor with the elements of input as the diagonal, If input is a tensor with more than one dimension, then returns a 2-D tensor with diagonal elements equal to a flattened input.

Ascend GPU CPU

mindspore.ops.diagonal

Returns diagonals of the input tensor along specified dimension.

Ascend GPU CPU

mindspore.ops.diagonal_scatter

Embeds the values of the src tensor into input along the diagonal elements of input, with respect to dim1 and dim2 .

Ascend GPU CPU

mindspore.ops.diag_embed

Create a tensor whose diagonals of certain 2D planes (specified by dim1 and dim2) are filled by input, and all other positions are set to 0.

Ascend GPU CPU

mindspore.ops.dyn_shape

Returns the shape of the input tensor.

Ascend GPU CPU

mindspore.ops.dsplit

Splits a tensor along the 3rd axis.

Ascend GPU CPU

mindspore.ops.dstack

Stacks tensors along the third axis.

Ascend GPU CPU

mindspore.ops.einsum

According to the Einstein summation Convention (Einsum), the product of the input tensor elements is summed along the specified dimension.

GPU

mindspore.ops.expand_dims

Adds an additional axis to input tensor.

Ascend GPU CPU

mindspore.ops.flip

Reverses elements in a tensor along the given dims.

Ascend GPU CPU

mindspore.ops.fliplr

Flip the input tensor in left/right direction.

Ascend GPU CPU

mindspore.ops.flipud

Flip the input tensor in up/down direction.

Ascend 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 the specified dim and indices.

Ascend GPU CPU

mindspore.ops.gather_nd

Gathers slices from the input tensor by specified indices.

Ascend GPU CPU

mindspore.ops.hstack

Stacks tensors in sequence horizontally.

Ascend GPU CPU

mindspore.ops.hsplit

Splits a tensor into multiple sub-tensors horizontally.

Ascend GPU CPU

mindspore.ops.index_add

Add the elements of input y into input x along the given axis and indices.

Ascend GPU CPU

mindspore.ops.index_fill

Fills the elements of the input x with value along the given axis and indices.

Ascend GPU CPU

mindspore.ops.index_select

Select the input tensor according to the specified axis and index and return a new tensor.

Ascend GPU CPU

mindspore.ops.inplace_add

Add x to v according to the indices.

Ascend GPU CPU

mindspore.ops.inplace_index_add

Add updates to var according to the indices and axis.

Ascend CPU

mindspore.ops.inplace_sub

Subtract v in x according to the indices.

Ascend GPU CPU

mindspore.ops.inplace_update

Updates x to v according to the indices.

GPU CPU

mindspore.ops.is_nonzero

Determine whether the input Tensor contains 0 or False.

Ascend GPU CPU

mindspore.ops.masked_fill

Fills elements of tensor with value where mask is True.

Ascend GPU CPU

mindspore.ops.masked_select

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

Ascend GPU CPU

mindspore.ops.meshgrid

Creates grids of coordinates specified by the 1D inputs。

Ascend GPU CPU

mindspore.ops.narrow

Slice the tensor from the start position with a length of length along axis .

Ascend GPU CPU

mindspore.ops.moveaxis

Move axis of an array from source to destination.

Ascend GPU CPU

mindspore.ops.movedim

Swap two dimensions of the input tensor.

Ascend GPU CPU

mindspore.ops.nan_to_num

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

Ascend CPU

mindspore.ops.nanmean

Computes the mean of input in specified dimension, ignoring NaN.

Ascend GPU CPU

mindspore.ops.nanmedian

Computes the median and indices of input in specified dimension, ignoring NaN.

CPU

mindspore.ops.nansum

Computes sum of input over a given dimension, ignoring NaN.

Ascend GPU CPU

mindspore.ops.normal

Return a random tensor that conforms to the normal (Gaussian) distribution.

Ascend GPU CPU

mindspore.ops.nonzero

Return the positions of all non-zero values.

Ascend GPU CPU

mindspore.ops.numel

Return the total number of elements in the tensor.

Ascend GPU CPU

mindspore.ops.permute

Permute the input tensor along the specified axis.

Ascend GPU CPU

mindspore.ops.population_count

Calculate the number of 1 bits in the binary representation of each element in the input tensor.

Ascend GPU CPU

mindspore.ops.rank

Return the rank of a tensor.

Ascend GPU CPU

mindspore.ops.repeat_elements

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

Ascend GPU CPU

mindspore.ops.repeat_interleave

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

Ascend GPU CPU

mindspore.ops.reshape

Reshape the input tensor based on the given shape.

Ascend GPU CPU

mindspore.ops.reverse_sequence

Partially reverse the input sequence.

Ascend GPU CPU

mindspore.ops.roll

Roll the elements of a tensor along a dimension.

Ascend GPU

mindspore.ops.row_stack

Alias for mindspore.ops.vstack() .

Ascend GPU CPU

mindspore.ops.scatter

Update the value in src to input according to the specified index.

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 input (if True) or other (if False) based on the value of each element.

Ascend GPU CPU

mindspore.ops.select_scatter

On the specified dimension axis of input , src is scattered into input on the specified index of input .

Ascend GPU CPU

mindspore.ops.sequence_mask

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

GPU CPU

mindspore.ops.shape

Return the shape of the input tensor.

Ascend GPU CPU

mindspore.ops.shuffle

Randomly shuffle a tensor along its first dimension.

Ascend GPU CPU

mindspore.ops.size

Count the total number of elements in input_x .

Ascend GPU CPU

mindspore.ops.slice

Slice a tensor in the specified shape.

Ascend GPU CPU

mindspore.ops.slice_scatter

Embed src into the sliced input along the specified axis .

Ascend GPU CPU

mindspore.ops.sort

Sort the elements of the input tensor along the given axis.

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 the mean of sparse segments in the input tensor.

GPU CPU

mindspore.ops.split

Split the tensor into chunks along the given axis.

Ascend GPU CPU

mindspore.ops.squeeze

Remove length one axes from input tensor.

Ascend GPU CPU

mindspore.ops.stack

Stack input 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.sum

Calculate sum of tensor elements over a given dim.

Ascend GPU CPU

mindspore.ops.swapaxes

Interchange two axes of a tensor.

Ascend GPU CPU

mindspore.ops.swapdims

Interchange two dims of a tensor.

Ascend GPU CPU

mindspore.ops.tensor_scatter_add

Return a new tensor by adding the values from updates in input_x indicated by indices .

Ascend GPU CPU

mindspore.ops.tensor_scatter_div

Return a new tensor which input_x is divided by the values from updates indicated by indices .

GPU CPU

mindspore.ops.tensor_scatter_max

Return a new tensor by performing a maximum update on input_x at the specified indices with the given update values.

GPU CPU

mindspore.ops.tensor_scatter_min

Return a new tensor by performing a minimum update on input_x at the specified indices with the given update values.

Ascend GPU CPU

mindspore.ops.tensor_scatter_mul

Return a new tensor by performing a multiplication update on input_x at the specified indices with the given update values.

GPU CPU

mindspore.ops.tensor_scatter_sub

Return a new tensor by performing a subtraction update on input_x at the specified indices with the given update values.

Ascend GPU CPU

mindspore.ops.tensor_scatter_elements

Return a new tensor by performing a specified operation update on input_x at the specified indices with the given update values.

Ascend GPU CPU

mindspore.ops.tensor_split

Split the input tensor into multiple subtensors according to the specified indices or chunks.

Ascend GPU CPU

mindspore.ops.tile

Creates a new tensor by repeating the elements in the input tensor dims times.

Ascend GPU CPU

mindspore.ops.tril

Zero the input tensor above the diagonal specified.

Ascend GPU CPU

mindspore.ops.triu

Zero the input tensor below the diagonal specified.

Ascend GPU CPU

mindspore.ops.transpose

Transpose dimensions of the input tensor according to input permutation.

Ascend GPU CPU

mindspore.ops.unbind

Remove a tensor dimension, return a tuple of all slices along a given dimension.

Ascend GPU CPU

mindspore.ops.unique

Remove duplicate elements from the input tensor.

Ascend GPU CPU

mindspore.ops.unique_consecutive

Remove consecutive duplicate elements in the input tensor, retaining only the first occurrence from each repeated group.

Ascend GPU CPU

mindspore.ops.unsorted_segment_max

Compute the maximum of the input tensor along segments.

Ascend GPU CPU

mindspore.ops.unsorted_segment_min

Compute the minimum of the input tensor along segments.

Ascend GPU CPU

mindspore.ops.unsorted_segment_prod

Compute the product of the input tensor along segments.

Ascend GPU CPU

mindspore.ops.unsorted_segment_sum

Compute the sum of the input tensor along segments.

Ascend GPU CPU

mindspore.ops.unsqueeze

Adds an additional dimension to the input tensor at the given dimension.

Ascend GPU CPU

mindspore.ops.unstack

Unstack the input tensor along the specified axis.

Ascend GPU CPU

mindspore.ops.view_as_real

Return a real tensor with the last dimension of size 2, composed of the real and imaginary parts of the complex elements in the input tensor.

GPU CPU

mindspore.ops.vsplit

Split the input tensor with two or more dimensions, into multiple sub-tensors vertically according to indices_or_sections.

Ascend GPU CPU

mindspore.ops.vstack

Stacks tensors in sequence vertically.

Ascend GPU CPU

mindspore.ops.where

Return a tensor in which the elements are selected from input or other based on the condition.

Ascend GPU CPU

mindspore.ops.cross

Compute the cross product of two input tensors along the specified dimension.

Ascend CPU

mindspore.ops.renorm

Returns a tensor where each subtensor along the specified dimension is renormalized such that its p norm is less than or equal to maxnorm.

Ascend GPU CPU

Type Cast

API Name

Description

Supported Platforms

mindspore.ops.cast

Returns a tensor with the new specified data type.

Ascend GPU CPU

mindspore.ops.is_tensor

Check whether the input object is mindspore.Tensor .

Ascend GPU CPU

mindspore.ops.scalar_to_tensor

Converts a scalar to a tensor with the specified dtype.

Ascend GPU CPU

mindspore.ops.tuple_to_array

Converts a tuple to a tensor.

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

mindspore.ops.clip_by_norm

The input Tensor is cropped based on norm.

Ascend GPU CPU

Mathematical Functions

Element-wise Operations

API Name

Description

Supported Platforms

mindspore.ops.abs

Compute the 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

Return the element-wise sum of all input tensors.

Ascend GPU

mindspore.ops.acos

Compute arccosine of each element in input tensors.

Ascend GPU CPU

mindspore.ops.arccos

Alias for mindspore.ops.acos() .

Ascend GPU CPU

mindspore.ops.acosh

Computes inverse hyperbolic cosine of each element in inputs tensors.

Ascend GPU CPU

mindspore.ops.add

Compute the element-wise sum of the two input tensors.

Ascend GPU CPU

mindspore.ops.addcdiv

Divide tensor1 by tensor2 element-wise, multiply the result by the scalar value , and add it to input .

Ascend GPU CPU

mindspore.ops.addcmul

Multiply tensor1 by tensor2 element-wise, scale the result by the scalar value , and add it to input .

Ascend GPU CPU

mindspore.ops.addmv

Multiply the matrix mat and vector vec , and then add the result to the input .

Ascend GPU CPU

mindspore.ops.addn

Return the element-wise sum of all input tensors.

Ascend GPU CPU

mindspore.ops.angle

Returns the element-wise angle of the given complex tensor.

Ascend`` GPU CPU

mindspore.ops.arccosh

Alias for mindspore.ops.acosh().

Ascend GPU CPU

mindspore.ops.arcsin

Alias for mindspore.ops.asin().

Ascend GPU CPU

mindspore.ops.arcsinh

Alias for mindspore.ops.asinh().

Ascend GPU CPU

mindspore.ops.arctan

Alias for mindspore.ops.atan().

Ascend GPU CPU

mindspore.ops.arctanh

Alias for mindspore.ops.atanh().

Ascend GPU CPU

mindspore.ops.arctan2

Alias for 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 input/other element-wise.

Ascend GPU CPU

mindspore.ops.atanh

Computes inverse hyperbolic tangent of the input element-wise.

Ascend GPU CPU

mindspore.ops.atleast_1d

Returns a one-dimensional tensor of each zero-dimensional tensor, while tensors with one or more dimensions remain unchanged.

Ascend GPU CPU

mindspore.ops.atleast_2d

Returns a 2-dimensional tensor of each tensor, while tensors with two or more dimensions remain unchanged.

Ascend GPU CPU

mindspore.ops.atleast_3d

Returns a 3-dimensional tensor of each tensor, while tensors with three or more dimensions remain unchanged.

Ascend GPU CPU

mindspore.ops.bessel_i0

Computes the zeroth order modified Bessel function of the first kind for each element input.

GPU CPU

mindspore.ops.bessel_i0e

Computes the exponentially scaled zeroth order modified Bessel function of the first kind for each element input.

GPU CPU

mindspore.ops.bessel_i1

Computes the first order modified Bessel function of the first kind for each element input.

GPU CPU

mindspore.ops.bessel_i1e

Computes the exponentially scaled first order modified Bessel function of the first kind for each element input.

GPU CPU

mindspore.ops.bessel_j0

Computes the zeroth order Bessel function of the first kind for each element input.

GPU CPU

mindspore.ops.bessel_j1

Computes the first order Bessel function of the first kind for each element input.

GPU CPU

mindspore.ops.bessel_k0

Computes the zeroth order modified Bessel function of the second kind for each element input.

GPU CPU

mindspore.ops.bessel_k0e

Computes the exponentially scaled zeroth order modified Bessel function of the second kind for each element input.

GPU CPU

mindspore.ops.bessel_k1

Computes the first order modified Bessel function of the second kind for each element input.

GPU CPU

mindspore.ops.bessel_k1e

Computes the exponentially scaled first order modified Bessel function of the second kind for each element input.

GPU CPU

mindspore.ops.bessel_y0

Computes the zeroth order Bessel function of the second kind for each element input.

GPU CPU

mindspore.ops.bessel_y1

Computes the first order Bessel function of the second kind for each element input.

GPU CPU

mindspore.ops.bitwise_and

Compute the bitwise AND of two input tensors.

Ascend GPU CPU

mindspore.ops.bitwise_left_shift

Perform a left bitwise shift operation on the input element-wise, where the number of bits to shift is specified by other.

Ascend GPU CPU

mindspore.ops.bitwise_or

Compute the bitwise OR of two input tensors.

Ascend GPU CPU

mindspore.ops.bitwise_right_shift

Perform a right bitwise shift operation on the input element-wise, where the number of bits to shift is specified by other.

Ascend GPU CPU

mindspore.ops.bitwise_xor

Compute the bitwise XOR of two input tensors.

Ascend GPU CPU

mindspore.ops.ceil

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

Ascend GPU CPU

mindspore.ops.clamp

Clamp all elements of the input tensor within the range [min, max].

Ascend GPU CPU

mindspore.ops.clip

Alias for mindspore.ops.clamp() .

Ascend GPU CPU

mindspore.ops.combinations

Return all r-length subsequences of input tensor.

Ascend GPU CPU

mindspore.ops.copysign

Create a float tensor composed of the absolute values of x and the signs of other .

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

Calculate cosine similarity between two input tensors along the specified dimension.

Ascend GPU CPU

mindspore.ops.cov

Return the covariance matrix of the input tensor, where the rows of the input tensor represent variables and the columns represent observations.

Ascend GPU CPU

mindspore.ops.diff

Computes the n-th forward difference along the given axis.

Ascend GPU CPU

mindspore.ops.deg2rad

Convert angles from degrees to radians element-wise.

Ascend GPU CPU

mindspore.ops.digamma

Computes the logarithmic derivative of the gamma function on input tensor.

GPU CPU

mindspore.ops.div

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

Ascend GPU CPU

mindspore.ops.divide

Alias for mindspore.ops.div() .

Ascend GPU CPU

mindspore.ops.erf

Compute the Gauss error of input tensor element-wise.

Ascend GPU CPU

mindspore.ops.erfc

Compute the complementary error function of input tensor element-wise.

Ascend GPU CPU

mindspore.ops.erfinv

Compute the inverse error of input tensor element-wise.

Ascend GPU CPU

mindspore.ops.exp

Compute exponential of the input tensor element-wise.

Ascend GPU CPU

mindspore.ops.exp2

Compute base two exponential of the input tensor element-wise.

Ascend GPU CPU

mindspore.ops.expm1

Compute exponential of the input tensor, then minus 1, 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

Alias for mindspore.ops.floor_divide() .

Ascend GPU CPU

mindspore.ops.floor_divide

Compute element-wise division of input by other and floor the result.

Ascend GPU CPU

mindspore.ops.floor_mod

Compute the remainder of element-wise flooring division of first input by second input.

Ascend GPU CPU

mindspore.ops.float_power

Computes the first input to the power of the second input.

GPU CPU

mindspore.ops.fmax

Compute the maximum of input tensors element-wise.

CPU

mindspore.ops.fmod

Compute the remainder of element-wise division of first input by the second input.

Ascend GPU CPU

mindspore.ops.frac

Return the fractional part of each element in the input tensor.

Ascend GPU CPU

mindspore.ops.gcd

Computes greatest common divisor of input tensors element-wise.

Ascend GPU CPU

mindspore.ops.hypot

Given the legs of a right triangle, return its hypotenuse, element-wise.

Ascend GPU CPU

mindspore.ops.igamma

Calculates lower regularized incomplete Gamma function.

Ascend GPU CPU

mindspore.ops.igammac

Calculates upper regularized incomplete Gamma function.

Ascend GPU CPU

mindspore.ops.imag

Return a new tensor containing imaginary value of the input tensor, element-wise.

Ascend GPU CPU

mindspore.ops.i0

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

GPU CPU

mindspore.ops.inv

Computes Reciprocal of input tensor element-wise.

Ascend GPU CPU

mindspore.ops.invert

Flip all bits of input tensor element-wise.

Ascend GPU CPU

mindspore.ops.lcm

Computes least common multiplier of input tensors element-wise.

Ascend GPU CPU

mindspore.ops.ldexp

Multiplies input tensor by \(2^{other}\) element-wise.

Ascend GPU CPU

mindspore.ops.lerp

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

Ascend GPU CPU

mindspore.ops.log

Compute the natural logarithm of the input tensor element-wise.

Ascend GPU CPU

mindspore.ops.log2

Compute the logarithm to the base 2 of the input tensor element-wise.

Ascend GPU CPU

mindspore.ops.log10

Compute the logarithm to the base 10 of the input tensor element-wise.

Ascend GPU CPU

mindspore.ops.log1p

Compute the natural logarithm of (tensor + 1) element-wise.

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

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

Ascend GPU CPU

mindspore.ops.logical_not

Compute the "logical NOT" of the input tensor element-wise.

Ascend GPU CPU

mindspore.ops.logical_or

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

Ascend GPU CPU

mindspore.ops.logical_xor

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

Ascend CPU

mindspore.ops.logit

Calculate the logit of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.mul

Multiplies two tensors element-wise.

Ascend GPU CPU

mindspore.ops.multiply

Alias for mindspore.ops.asinh().

Ascend GPU CPU

mindspore.ops.mvlgamma

Compute the multivariate log-gamma function with dimension p element-wise.

Ascend GPU CPU

mindspore.ops.neg

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

Ascend GPU CPU

mindspore.ops.negative

Alias for mindspore.ops.neg() .

Ascend GPU CPU

mindspore.ops.nextafter

Returns the next representable floating-point value after input towards other element-wise.

Ascend GPU CPU

mindspore.ops.polar

Converts polar coordinates to Cartesian coordinates.

Ascend GPU CPU

mindspore.ops.polygamma

Computes the \(n\)-th derivative of the polygamma function on input.

GPU CPU

mindspore.ops.positive

Return self tensor.

Ascend GPU CPU

mindspore.ops.pow

Calculate the exponent power of each element in input.

Ascend GPU CPU

mindspore.ops.rad2deg

Converts angles in radians to angles in degrees element-wise.

Ascend GPU CPU

mindspore.ops.ravel

Expand the multidimensional Tensor into 1D along the 0 axis direction.

Ascend GPU CPU

mindspore.ops.real

Return a tensor that is the real part of the input.

Ascend GPU CPU

mindspore.ops.reciprocal

Returns reciprocal of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.remainder

Compute the remainder of division for the input tensor element-wise.

Ascend GPU CPU

mindspore.ops.rot90

Rotate a n-D tensor by 90 degrees in the plane specified by dims axis.

Ascend GPU CPU

mindspore.ops.round

Round elements of input to the nearest integer.

Ascend GPU CPU

mindspore.ops.rsqrt

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

Ascend GPU CPU

mindspore.ops.sgn

Extension of mindspore.ops.sign() in complex domain.

Ascend GPU CPU

mindspore.ops.sign

Return an element-wise indication of the sign of a number.

Ascend GPU CPU

mindspore.ops.signbit

Determine the symbol of each element.

Ascend GPU CPU

mindspore.ops.sin

Compute sine of the input tensor element-wise.

Ascend GPU CPU

mindspore.ops.sinc

Compute the normalized sinc of input.

Ascend GPU CPU

mindspore.ops.sinh

Compute hyperbolic sine of the input element-wise.

Ascend GPU CPU

mindspore.ops.sqrt

Return sqrt of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.square

Return square of a tensor element-wise.

Ascend GPU CPU

mindspore.ops.sub

Subtract the second input from the first input element-wise.

Ascend GPU CPU

mindspore.ops.subtract

Subtract other scaled by alpha from input.

Ascend GPU CPU

mindspore.ops.t

Transpose a 2-D tensor.

Ascend GPU CPU

mindspore.ops.tan

Computes tangent of input element-wise.

Ascend GPU CPU

mindspore.ops.tanhshrink

Apply the element-wise Tanhshrink function.

Ascend GPU CPU

mindspore.ops.trapz

Compute the trapezoidal rule along dim.

Ascend GPU CPU

mindspore.ops.tril_indices

Return a 2-by-N tensor containing the indices of the lower triangular elements of a row * col matrix.

Ascend GPU CPU

mindspore.ops.triu_indices

Return a 2-by-N tensor containing the indices of the upper triangular elements of a row * col matrix.

Ascend GPU CPU

mindspore.ops.true_divide

Alias for mindspore.ops.div() with rounding_mode=None .

Ascend GPU CPU

mindspore.ops.trunc

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

Ascend GPU CPU

mindspore.ops.truncate_div

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

Ascend GPU CPU

mindspore.ops.truncate_mod

Return the remainder of division element-wise.

Ascend GPU CPU

mindspore.ops.xdivy

Divide x by y element-wise.

Ascend GPU CPU

mindspore.ops.xlogy

Compute input multiplied by the logarithm of other element-wise.

Ascend GPU CPU

mindspore.ops.zeta

Elemental-wise compute the Hurwitz zeta function values.

Ascend GPU CPU

Reduction Functions

API Name

Description

Supported Platforms

mindspore.ops.all

Tests if all element in input evaluates to True along the given axes.

Ascend GPU CPU

mindspore.ops.amax

Return the maximum values along the given axis of the tensor.

Ascend GPU CPU

mindspore.ops.amin

Return the minimum values along the given axis of the tensor.

Ascend GPU CPU

mindspore.ops.aminmax

Return the minimum values and maximum values along the given axes of the tensor.

Ascend GPU CPU

mindspore.ops.any

Tests if any element in input evaluates to True along the given axes.

Ascend GPU CPU

mindspore.ops.argmax

Return the indices of the maximum values along a specified dimension of the tensor.

Ascend GPU CPU

mindspore.ops.argmin

Return the indices of the minimum values along a specified dimension of the tensor.

Ascend GPU CPU

mindspore.ops.cummax

Return the cumulative maximum values and their indices along the given axis of the tensor.

Ascend GPU CPU

mindspore.ops.cummin

Return the cumulative minimum values and their indices along the given axis of the tensor.

Ascend GPU CPU

mindspore.ops.cumprod

Return the cumulative product along the given dimension of the tensor.

Ascend GPU CPU

mindspore.ops.cumsum

Return the cumulative sum along the given axis of the tensor.

Ascend GPU CPU

mindspore.ops.histc

Computes the histogram of a tensor.

Ascend CPU

mindspore.ops.logcumsumexp

Calculate the log of cumulative summed exponentials of the tensor along a specified dimension.

Ascend CPU GPU

mindspore.ops.logsumexp

Calculate the log of summed exponentials of the tensor along a specified dimension.

Ascend GPU CPU

mindspore.ops.max

Return the maximum values and their indices along the given axis of the tensor.

Ascend GPU CPU

mindspore.ops.mean

Compute the mean(s) of the tensor along the specified axis(axes).

Ascend GPU CPU

mindspore.ops.median

Return the median(s) and indice(s) of the tensor along the specified axis.

GPU CPU

mindspore.ops.min

Return the minimum values and their indices along the given axis of the tensor.

Ascend GPU CPU

mindspore.ops.norm

Compute the matrix norm or vector norm of the tensor along a specified dimension.

Ascend GPU CPU

mindspore.ops.prod

Return the product(s) of the tensor along the specified axis(axes).

Ascend GPU CPU

mindspore.ops.std

Compute the standard deviation of the tensor along a specified axis.

Ascend GPU CPU

mindspore.ops.std_mean

Compute the standard deviation and the mean of the tensor along a specified axis.

Ascend GPU CPU

mindspore.ops.var

Compute the variance of the tensor along a specified axis.

Ascend GPU CPU

mindspore.ops.var_mean

Compute the variance and the mean of the tensor along a specified axis.

Ascend GPU CPU

Comparison Functions

API Name

Description

Supported Platforms

mindspore.ops.argsort

Return the indices that sort the tensor along the specified axis.

Ascend GPU CPU

mindspore.ops.approximate_equal

Return a boolean tensor where two tensors are element-wise equal within a tolerance.

Ascend GPU CPU

mindspore.ops.bucketize

Return the indices of the buckets to which each element in the input tensor belongs.

Ascend GPU CPU

mindspore.ops.eq

Compute the equivalence of the two inputs element-wise.

Ascend GPU CPU

mindspore.ops.equal

Compute the equivalence of the two inputs element-wise.

Ascend GPU CPU

mindspore.ops.ge

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

Ascend GPU CPU

mindspore.ops.greater

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

Ascend GPU CPU

mindspore.ops.greater_equal

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

Ascend GPU CPU

mindspore.ops.gt

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

Ascend GPU CPU

mindspore.ops.intopk

Return whether the elements in second input tensor exist among the top k elements of the first input tensor.

Ascend GPU CPU

mindspore.ops.isclose

Return a boolean tensor where two tensors are element-wise equal within a tolerance.

Ascend GPU CPU

mindspore.ops.isfinite

Return a boolean tensor indicating which elements are finite.

Ascend GPU CPU

mindspore.ops.isinf

Return a boolean tensor indicating which elements are +/- inifnity.

Ascend CPU GPU

mindspore.ops.isnan

Return a boolean tensor indicating which elements are NaN.

Ascend GPU CPU

mindspore.ops.isneginf

Return a boolean tensor indicating which elements are negative infinity.

Ascend GPU CPU

mindspore.ops.isposinf

Return a boolean tensor indicating which elements are positive infinity.

Ascend GPU CPU

mindspore.ops.isreal

Return a boolean tensor indicating which elements are real.

GPU CPU

mindspore.ops.is_complex

Return a boolean tensor indicating which elements are complex.

Ascend GPU CPU

mindspore.ops.is_floating_point

If the data type of the tensor is a floating point data type, return True.

Ascend GPU CPU

mindspore.ops.le

Compute the value of \(input <= other\) element-wise.

Ascend GPU CPU

mindspore.ops.less

Compute the value of \(input < other\) element-wise.

Ascend GPU CPU

mindspore.ops.less_equal

Compute the value of \(input <= other\) element-wise.

Ascend GPU CPU

mindspore.ops.lt

Alias for mindspore.ops.less() .

Ascend GPU CPU

mindspore.ops.maximum

Compute the maximum of the two input tensors element-wise.

Ascend GPU CPU

mindspore.ops.minimum

Compute the minimum of the two input tensors element-wise.

Ascend GPU CPU

mindspore.ops.msort

Return a tensor obtained by sorting the input tensor in ascending order along its first dimension.

Ascend GPU CPU

mindspore.ops.ne

Compute the non-equivalence of two inputs element-wise.

Ascend GPU CPU

mindspore.ops.not_equal

Alias for mindspore.ops.ne() .

Ascend GPU CPU

mindspore.ops.searchsorted

Return the position indices where the elements can be inserted into the input tensor to maintain the increasing order of the input tensor.

Ascend GPU CPU

mindspore.ops.topk

Return the top k largest or smallest elements of the input tensor along a specified dimension.

Ascend GPU CPU

Linear Algebraic Functions

API Name

Description

Supported Platforms

mindspore.ops.addbmm

Apply batch matrix multiplication to batch1 and batch2, with a reduced add step and add input to the result.

Ascend GPU CPU

mindspore.ops.addmm

Multiply matrix mat1 and matrix mat2.

Ascend GPU CPU

mindspore.ops.addr

Compute the outer product of two vector vec1 and vec2, and add the resulting matrix to x.

Ascend GPU CPU

mindspore.ops.adjoint

Calculate the conjugation of tensor element-wise, and transpose the last two dimensions.

Ascend GPU CPU

mindspore.ops.baddbmm

Perform a batch matrix-matrix product of matrices in batch1 and batch2 , input is added to the final result.

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

Perform a batch matrix-matrix product of matrices in input tensors.

Ascend GPU CPU

mindspore.ops.cholesky

Return the Cholesky decomposition of zero or more batch dimensions consisting of symmetric positive-definite matrices.

GPU CPU

mindspore.ops.cholesky_solve

Computes the solution of a set of linear equations with a positive definite matrix, according to its Cholesky decomposition factor input2 .

Ascend GPU CPU

mindspore.ops.cond

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

GPU CPU

mindspore.ops.dot

Computation a dot product of two input tensors.

Ascend GPU CPU

mindspore.ops.eigvals

Compute the eigenvalues of a square matrix.

Ascend CPU

mindspore.ops.geqrf

Perform a QR decomposition on the input tensor \(A = QR\).

Ascend GPU CPU

mindspore.ops.ger

Calculate the outer product of two arrays input and vec2.

Ascend GPU CPU

mindspore.ops.inner

Return the dot product of two 1-D tensors.

Ascend GPU CPU

mindspore.ops.inverse

Compute the inverse of the input matrix.

GPU CPU

mindspore.ops.kron

Compute the Kronecker product of two tensors.

Ascend GPU CPU

mindspore.ops.logdet

Calculate log determinant of one or a batch of square matrices.

CPU

mindspore.ops.lu_solve

Compute the solution to a system of linear equations \(Ay = b\).

Ascend GPU CPU

mindspore.ops.lu_unpack

Unpack the LU decomposition returned by mindspore.scipy.linalg.lu_factor() into the P, L, U matrices.

GPU CPU

mindspore.ops.matmul

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

Ascend GPU CPU

mindspore.ops.matrix_solve

Solves systems of linear equations.

Ascend CPU

mindspore.ops.matrix_diag

Return 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

Return a tensor that retains the values of the specified diagonal while setting all other elements to zero.

Ascend GPU CPU

mindspore.ops.matrix_set_diag

Return a tensor by replacing the elements on the k[0]-th to k[1]-th diagonals of the matrix x with the values from the input diagonal .

Ascend GPU CPU

mindspore.ops.mm

Returns the matrix product of two arrays.

Ascend GPU CPU

mindspore.ops.mv

Multiplies matrix mat and vector vec.

Ascend GPU CPU

mindspore.ops.outer

Compute outer product of two tensors.

Ascend GPU CPU

mindspore.ops.orgqr

Compute the first \(N\) columns of a product of Householder matrices.

Ascend GPU CPU

mindspore.ops.ormqr

Calculates the product of a matrix other and a matrix Q (represented by Householder vectors input and Householder reflection coefficients tau).

GPU

mindspore.ops.pinv

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

CPU

mindspore.ops.svd

Computes the singular value decompositions of one or more matrices.

Ascend GPU CPU

mindspore.ops.slogdet

Computes the sign and the log of the absolute value of the determinant of one or more square matrices.

Ascend GPU CPU

mindspore.ops.trace

Return the sum of the elements along the diagonal of the input tensor.

Ascend GPU CPU

mindspore.ops.tensor_dot

Compute the tensor dot product along the specified axes.

Ascend GPU CPU

mindspore.ops.vander

Generates a Vandermonde matrix.

Ascend GPU CPU

mindspore.ops.vecdot

Calculates the dot product of two batches of vectors along the specified dimension.

Ascend GPU CPU

Spectral Functions

API Name

Description

Supported Platforms

mindspore.ops.bartlett_window

Bartlett window function.

Ascend GPU CPU

mindspore.ops.blackman_window

Blackman window function.

Ascend GPU CPU

mindspore.ops.hamming_window

Hamming window function.

Ascend GPU CPU

mindspore.ops.hann_window

Hann window function.

Ascend GPU CPU

mindspore.ops.kaiser_window

Kaiser window function.

Ascend GPU CPU

Neural Network Layer Functions

Neural Network

API Name

Description

Supported Platforms

mindspore.ops.adaptive_avg_pool1d

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

Ascend GPU CPU

mindspore.ops.adaptive_avg_pool2d

Performs 2D adaptive average pooling on a multi-plane input signal.

Ascend GPU CPU

mindspore.ops.adaptive_avg_pool3d

Performs 3D adaptive average pooling on a multi-plane input signal.

Ascend GPU CPU

mindspore.ops.adaptive_max_pool1d

Applies a 1D adaptive maximum pooling over an input Tensor which can be regarded as a composition of 1D input planes.

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

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

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

mindspore.ops.batch_norm

Batch Normalization for input data and updated parameters.

Ascend GPU CPU

mindspore.ops.bias_add

Returns the sum of the input_x and the bias Tensor.

Ascend GPU CPU

mindspore.ops.bidense

Applies bilinear dense connected layer for input1 and input2.

Ascend GPU CPU

mindspore.ops.ctc_greedy_decoder

Performs greedy decoding on the logits given in inputs.

Ascend GPU CPU

mindspore.ops.conv1d

Applies a 1D convolution over an input tensor.

Ascend GPU

mindspore.ops.conv2d

Applies a 2D convolution over an input tensor.

Ascend GPU

mindspore.ops.conv3d

Applies a 3D convolution over an input tensor.

Ascend GPU

mindspore.ops.deformable_conv2d

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

Ascend GPU CPU

mindspore.ops.dense

Applies the dense connected operation to the input.

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

Retrieve the word embeddings in weight using indices specified in input.

Ascend

mindspore.ops.flatten

Flatten a tensor along dimensions from start_dim to start_dim.

Ascend GPU CPU

mindspore.ops.fold

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

Ascend GPU CPU

mindspore.ops.fractional_max_pool3d

Applies the 3D FractionalMaxPool operation over input.

GPU CPU

mindspore.ops.fused_infer_attention_score

This is a FlashAttention function designed for both incremental and full inference scenarios.

Ascend

mindspore.ops.speed_fusion_attention

The interface is used for self-attention fusion computing.

Ascend

mindspore.ops.group_norm

Group Normalization over a mini-batch of inputs.

Ascend GPU CPU

mindspore.ops.layer_norm

Applies the Layer Normalization on the mini-batch input.

Ascend

mindspore.ops.lp_pool1d

Applying 1D LPPooling operation on an input Tensor can be regarded as forming a 1D input plane.

Ascend GPU CPU

mindspore.ops.lp_pool2d

Applying 2D LPPooling operation on an input Tensor can be regarded as forming a 2D input plane.

Ascend GPU CPU

mindspore.ops.lrn

Local Response Normalization.

GPU CPU

mindspore.ops.max_pool2d

Performs a 2D max pooling on the input Tensor.

Ascend GPU CPU

mindspore.ops.max_pool3d

Performs a 3D max pooling on the input Tensor.

Ascend GPU CPU

mindspore.ops.max_unpool1d

Computes the inverse of max_pool1d.

Ascend GPU CPU

mindspore.ops.max_unpool2d

Computes the inverse of max_pool2d.

Ascend GPU CPU

mindspore.ops.max_unpool3d

Computes the inverse of mindspore.ops.max_pool3d().

Ascend GPU CPU

mindspore.ops.moe_token_permute

Permute the tokens based on the indices.

Ascend

mindspore.ops.moe_token_unpermute

Unpermute a tensor of permuted tokens based on sorted indices, and optionally merge the tokens with their corresponding probabilities.

Ascend

mindspore.ops.incre_flash_attention

The interface for incremental inference.

Ascend

mindspore.ops.prompt_flash_attention

The interface for fully inference.

Ascend

mindspore.ops.flash_attention_score

Implement self-attention calculations in training scenarios.

Ascend

mindspore.ops.rms_norm

The RmsNorm(Root Mean Square Layer Normalization) operator is a normalization operation.

Ascend

mindspore.ops.unfold

Extracts sliding local blocks from a batched input tensor.

Ascend GPU CPU

Loss Functions

API Name

Description

Supported Platforms

mindspore.ops.binary_cross_entropy

Computes the binary cross entropy(Measure the difference information between two probability distributions) between predictive value logits and target value labels.

Ascend GPU CPU

mindspore.ops.binary_cross_entropy_with_logits

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

Ascend GPU CPU

mindspore.ops.cosine_embedding_loss

CosineEmbeddingLoss creates a criterion to measure the similarity between two tensors using cosine distance.

Ascend GPU CPU

mindspore.ops.cross_entropy

The cross entropy loss between input and target.

Ascend GPU CPU

mindspore.ops.ctc_loss

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

Ascend GPU CPU

mindspore.ops.gaussian_nll_loss

Gaussian negative log likelihood loss.

Ascend GPU CPU

mindspore.ops.hinge_embedding_loss

Measures Hinge Embedding Loss given an input Tensor intputs and a labels Tensor targets (containing 1 or -1).

Ascend GPU CPU

mindspore.ops.huber_loss

Calculates the error between the predicted value and the target value, which has the best of both the loss of mindspore.ops.l1_loss() and the loss of mindspore.ops.mse_loss().

Ascend GPU CPU

mindspore.ops.kl_div

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

Ascend GPU CPU

mindspore.ops.l1_loss

Calculate the mean absolute error between the input value and the target value.

Ascend GPU CPU

mindspore.ops.margin_ranking_loss

MarginRankingLoss creates a criterion that measures the loss.

Ascend GPU CPU

mindspore.ops.mse_loss

Calculates the mean squared error between the predicted value and the label value.

Ascend GPU CPU

mindspore.ops.multi_margin_loss

Hinge loss for optimizing a multi-class classification.

Ascend GPU CPU

mindspore.ops.multilabel_margin_loss

Hinge loss for optimizing a multi-label classification.

Ascend GPU

mindspore.ops.multilabel_soft_margin_loss

Calculates the MultiLabelSoftMarginLoss.

Ascend GPU CPU

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

mindspore.ops.soft_margin_loss

Calculate the soft margin loss of input and target.

Ascend GPU

mindspore.ops.triplet_margin_loss

TripletMarginLoss operation.

GPU

Activation Functions

API Name

Description

Supported Platforms

mindspore.ops.celu

celu activation function, computes celu (Continuously differentiable exponential linear units) of input tensors element-wise.

Ascend GPU CPU

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

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

Hard Sigmoid activation function.

Ascend GPU CPU

mindspore.ops.hardswish

Hard Swish activation function.

Ascend GPU CPU

mindspore.ops.hardtanh

Applies the hardtanh activation function element-wise.

Ascend GPU CPU

mindspore.ops.leaky_relu

leaky_relu activation function.

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

Applies LogSigmoid activation element-wise.

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

Randomized Leaky ReLU activation function.

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

Computes Sigmoid Linear Unit of input element-wise, also known as Swish function.

Ascend GPU CPU

mindspore.ops.softmax

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

Ascend GPU CPU

mindspore.ops.softmin

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

Ascend GPU CPU

mindspore.ops.softshrink

Soft Shrink activation function.

Ascend GPU CPU

mindspore.ops.softsign

SoftSign activation function.

Ascend GPU CPU

mindspore.ops.swiglu

Computes SwiGLU (Swish-Gated Linear Unit activation function) of input tensor.

Ascend

mindspore.ops.tanh

Computes hyperbolic tangent of input element-wise.

Ascend GPU CPU

mindspore.ops.threshold

Returns each element of input after thresholding by thr as a Tensor.

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

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

Ascend GPU CPU

mindspore.ops.pdist

Calculates the distance between every pair of row vectors in the input using the p-norm.

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

Image Functions

API Name

Description

Supported Platforms

mindspore.ops.affine_grid

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

Ascend GPU CPU

mindspore.ops.bounding_box_decode

Decode the bounding box locations, calculate the offset, and convert the offset into a Bbox, which is used to mark the target in the subsequent images, etc.

Ascend GPU CPU

mindspore.ops.bounding_box_encode

Encode the bounding box locations, calculate the offset between the predicted bounding boxes and the real bounding boxes, and the offset will be used as a variable for the loss.

Ascend GPU CPU

mindspore.ops.col2im

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

Ascend GPU CPU

mindspore.ops.check_valid

Checks whether the bounding box is in the image.

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 and a flow-field grid, computes the output using input values and pixel locations from grid.

Ascend GPU CPU

mindspore.ops.interpolate

Samples the input Tensor to the given size or scale_factor by using one of the interpolate algorithms.

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 the PixelShuffle operation over input input which implements sub-pixel convolutions with stride \(1/r\) .

Ascend GPU CPU

mindspore.ops.pixel_unshuffle

Applies the PixelUnshuffle operation over input input which is the inverse of PixelShuffle.

Ascend GPU CPU

mindspore.ops.rotary_position_embedding

Implements the Rotary Position Embedding algorithm.

Ascend

mindspore.ops.rotated_iou

Calculate the overlap area between rotated rectangles.

Ascend

mindspore.ops.upsample

Alias for mindspore.ops.interpolate() .

Ascend GPU CPU

Parameter Operation Functions

API Name

Description

Supported Platforms

mindspore.ops.assign

Assigns a parameter or tensor with a value.

Ascend GPU CPU

mindspore.ops.assign_add

Updates a parameter or tensor by adding a value to it.

Ascend GPU CPU

mindspore.ops.assign_sub

Updates a parameter or tensor by subtracting a value from it.

Ascend GPU CPU

mindspore.ops.scatter_add

Perform an addition update on input_x based on the specified indices and update values.

Ascend GPU CPU

mindspore.ops.scatter_div

Perform a division update on input_x based on the specified indices and update values.

Ascend GPU CPU

mindspore.ops.scatter_min

Perform a minimum update on input_x based on the specified indices and update values.

Ascend GPU CPU

mindspore.ops.scatter_max

Perform a maximum update on input_x based on the specified indices and update values.

Ascend GPU CPU

mindspore.ops.scatter_mul

Perform a multiplication update on input_x based on the specified indices and update values.

Ascend GPU CPU

mindspore.ops.scatter_nd_add

Perform a sparse addition update on input_x based on the specified indices and update values.

Ascend GPU CPU

mindspore.ops.scatter_nd_div

Perform a sparse division update on input_x based on the specified indices and update values.

GPU CPU

mindspore.ops.scatter_nd_max

Perform a sparse maximum update on input_x based on the specified indices and update values.

Ascend GPU CPU

mindspore.ops.scatter_nd_min

Perform a sparse minimum update on input_x based on the specified indices and update values.

Ascend GPU CPU

mindspore.ops.scatter_nd_mul

Perform a sparse multiplication update on input_x based on the specified indices and update values.

GPU CPU

mindspore.ops.scatter_nd_sub

Perform a sparse subtraction update on input_x based on the specified indices and update values.

Ascend GPU CPU

mindspore.ops.scatter_update

Updates the input tensor values using the given input indices and update values.

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

mindspore.ops.tensordump

Save tensor in npy format.

Ascend

Sparse Functions

Warning

These are experimental APIs that are subject to change or deletion.

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

Warning

These are experimental APIs that are subject to change or deletion.

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_add

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

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_concat

concatenates the input SparseTensor(COO format) along the specified dimension.

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 the element-wise exponential of a COOTensor.

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.

GPU CPU

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

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

mindspore.ops.coo_tanh

Computes hyperbolic tangent of input element-wise.

Ascend GPU CPU

CSR Functions

Warning

These are experimental APIs that are subject to change or deletion.

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

Computes the linear combination of two input CSRTensors a and b.

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.

GPU CPU

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_mm

Return the matrix multiplication result of the right-multiply matrix (dense or CSRTensor) of the CSRTensor.

GPU

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

mindspore.ops.csr_tanh

Computes hyperbolic tangent of input element-wise.

Ascend GPU CPU

MC2 Functions

Warning

These are experimental APIs that are subject to change or deletion.

API Name

Description

Supported Platforms

mindspore.ops.all_gather_matmul

In the TP segmentation scenario, allgather and matmul are fused, and communication and computational pipelines are parallelized within the fusion operator.

Ascend

mindspore.ops.matmul_reduce_scatter

In the TP segmentation scenario, matmul and reducescatter are fused, and communication and computational pipelines are parallelized within the fusion operator.

Ascend