mindspore.mint

mindspore.mint provides a large number of functional, nn, optimizer interfaces. The API usages and functions are consistent with the mainstream usage in the industry for easy reference. The mint interface is currently an experimental interface and performs better than ops in graph mode of O0 and PyNative mode. Currently, the O2 (graph sinking mode) and CPU/GPU backend are not supported, and it will be gradually improved in the future.

The module import method is as follows:

from mindspore import mint

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

Tensor

Creation Operations

API Name

Description

Supported Platforms

mindspore.mint.arange

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

Ascend

mindspore.mint.bernoulli

Sample from the Bernoulli distribution and randomly set the i^{th} element of the output to (0 or 1) according to the i^{th} probability value given in the input.

Ascend

mindspore.mint.bincount

Count the occurrences of each value in the input.

Ascend

mindspore.mint.clone

Returns a copy of the input tensor.

Ascend

mindspore.mint.eye

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

Ascend

mindspore.mint.einsum

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

Ascend

mindspore.mint.empty

Creates a tensor with uninitialized data, whose shape, dtype and device are described by the argument size, dtype and device respectively.

Ascend

mindspore.mint.empty_like

Returns an uninitialized Tensor with the same shape as the input.

Ascend

mindspore.mint.full

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

Ascend

mindspore.mint.full_like

Return a Tensor of the same shape as input and filled with fill_value.

Ascend

mindspore.mint.linspace

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

Ascend

mindspore.mint.ones

Creates a tensor filled with value ones.

Ascend

mindspore.mint.ones_like

Creates a tensor filled with 1, with the same shape as input, and its data type is determined by the given dtype.

Ascend

mindspore.mint.randint

Returns a new tensor filled with integer numbers from the uniform distribution over an interval [low,high) based on the given shape and dtype.

Ascend

mindspore.mint.randint_like

Returns a new tensor filled with integer numbers from the uniform distribution over an interval [low,high) based on the given dtype and shape of the input tensor.

Ascend

mindspore.mint.randn

Returns a new tensor filled with numbers from the normal distribution over an interval [0,1) based on the given shape and dtype.

Ascend

mindspore.mint.randn_like

Returns a new tensor filled with numbers from the normal distribution over an interval [0,1) based on the given dtype and shape of the input tensor.

Ascend

mindspore.mint.randperm

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

Ascend

mindspore.mint.zeros

Creates a tensor filled with 0 with shape described by size and fills it with value 0 in type of dtype.

Ascend

mindspore.mint.zeros_like

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

Ascend

Indexing, Slicing, Joining, Mutating Operations

API Name

Description

Supported Platforms

mindspore.mint.cat

Connect input tensors along with the given dimension.

Ascend

mindspore.mint.chunk

Cut the input Tensor into chunks sub-tensors along the specified axis.

Ascend

mindspore.mint.concat

Alias for mindspore.mint.cat().

Ascend

mindspore.mint.count_nonzero

Count the number of non-zero elements in the Tensor input on a given dimension dim.

Ascend

mindspore.mint.gather

Gather data from a tensor by indices.

Ascend

mindspore.mint.index_add

Accumulate the elements of alpha times source into the input by adding to the index in the order given in index.

Ascend

mindspore.mint.index_select

Generates a new Tensor that accesses the values of input along the specified dim dimension using the indices specified in index.

Ascend

mindspore.mint.masked_select

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

Ascend

mindspore.mint.permute

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

Ascend

mindspore.mint.reshape

Reshape the input tensor based on the given shape.

Ascend

mindspore.mint.scatter

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

Ascend

mindspore.mint.scatter_add

Add all elements in src to the index specified by index to input along dimension specified by dim.

Ascend

mindspore.mint.split

Splits the Tensor into chunks along the given dim.

Ascend

mindspore.mint.narrow

Obtains a tensor of a specified length at a specified start position along a specified axis.

Ascend

mindspore.mint.nonzero

Return the positions of all non-zero values.

Ascend

mindspore.mint.tile

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

Ascend

mindspore.mint.tril

Zero the input tensor above the diagonal specified.

Ascend

mindspore.mint.select

Slices the input tensor along the selected dimension at the given index.

Ascend

mindspore.mint.squeeze

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

Ascend

mindspore.mint.stack

Stacks a list of tensors in specified dim.

Ascend

mindspore.mint.swapaxes

Alias for mindspore.mint.transpose() .

Ascend

mindspore.mint.transpose

Interchange two axes of a tensor.

Ascend

mindspore.mint.triu

Zero the input tensor below the diagonal specified.

Ascend

mindspore.mint.unbind

Unbind a tensor dimension in specified axis.

Ascend

mindspore.mint.unique_consecutive

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

Ascend

mindspore.mint.unsqueeze

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

Ascend

mindspore.mint.where

Selects elements from input or other based on condition and returns a tensor.

Ascend

Random Sampling

API Name

Description

Supported Platforms

mindspore.mint.multinomial

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

Ascend

mindspore.mint.normal

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

Ascend

mindspore.mint.rand_like

Returns a new tensor that fills numbers from the uniform distribution over an interval [0,1) based on the given dtype and shape of the input tensor.

Ascend

mindspore.mint.rand

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

Ascend

Math Operations

Pointwise Operations

API Name

Description

Supported Platforms

mindspore.mint.abs

Compute the absolute value of a tensor element-wise.

Ascend

mindspore.mint.add

Adds scaled other value to self.

Ascend

mindspore.mint.addmv

Performs a matrix-vector product of mat and vec, and add the input vector input to the final result.

Ascend

mindspore.mint.acos

Computes arccosine of input tensors element-wise.

Ascend

mindspore.mint.acosh

Computes inverse hyperbolic cosine of the inputs element-wise.

Ascend

mindspore.mint.arccos

Alias for mindspore.mint.acos() .

Ascend

mindspore.mint.arccosh

Alias for mindspore.mint.acosh().

Ascend

mindspore.mint.arcsin

Alias for mindspore.mint.asin().

Ascend

mindspore.mint.arcsinh

Alias for mindspore.mint.asinh().

Ascend

mindspore.mint.arctan

Alias for mindspore.mint.atan().

Ascend

mindspore.mint.arctan2

Alias for mindspore.mint.atan2().

Ascend

mindspore.mint.arctanh

Alias for mindspore.mint.atanh().

Ascend

mindspore.mint.asin

Computes arcsine of input tensors element-wise.

Ascend

mindspore.mint.asinh

Computes inverse hyperbolic sine of the input element-wise.

Ascend

mindspore.mint.atan

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

Ascend

mindspore.mint.atan2

Returns arctangent of input/other element-wise.

Ascend

mindspore.mint.atanh

Computes inverse hyperbolic tangent of the input element-wise.

Ascend

mindspore.mint.bitwise_and

Returns bitwise and of two tensors element-wise.

Ascend

mindspore.mint.bitwise_or

Returns bitwise or of two tensors element-wise.

Ascend

mindspore.mint.bitwise_xor

Returns bitwise xor of two tensors element-wise.

Ascend

mindspore.mint.ceil

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

Ascend

mindspore.mint.clamp

Clamps tensor values between the specified minimum value and maximum value.

Ascend

mindspore.mint.cos

Computes cosine of input element-wise.

Ascend

mindspore.mint.cosh

Computes hyperbolic cosine of input element-wise.

Ascend

mindspore.mint.cross

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

Ascend

mindspore.mint.diff

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

Ascend

mindspore.mint.div

Divides each element of the input by the corresponding element of the other .

Ascend

mindspore.mint.divide

Alias for mindspore.mint.div() .

Ascend

mindspore.mint.erf

Compute the Gauss error of input tensor element-wise.

Ascend

mindspore.mint.erfc

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

Ascend

mindspore.mint.erfinv

Compute the inverse error of input tensor element-wise.

Ascend

mindspore.mint.exp

Compute exponential of the input tensor element-wise.

Ascend

mindspore.mint.exp2

Calculates the base-2 exponent of the Tensor input element by element.

Ascend

mindspore.mint.expm1

Compute exponential of the input tensor, then minus 1, element-wise.

Ascend

mindspore.mint.fix

Alias for mindspore.mint.trunc() .

Ascend

mindspore.mint.float_power

Computes input to the power of exponent element-wise in double precision, and always returns a mindspore.float64 tensor.

Ascend

mindspore.mint.floor

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

Ascend

mindspore.mint.fmod

Computes the floating-point remainder of the division operation input/other.

Ascend

mindspore.mint.frac

Calculates the fractional part of each element in the input.

Ascend

mindspore.mint.lerp

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

Ascend

mindspore.mint.log

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

Ascend

mindspore.mint.log1p

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

Ascend

mindspore.mint.log2

Returns the logarithm to the base 2 of a tensor element-wise.

Ascend

mindspore.mint.log10

Returns the logarithm to the base 10 of a tensor element-wise.

Ascend

mindspore.mint.logaddexp

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

Ascend

mindspore.mint.logaddexp2

Logarithm of the sum of exponentiations of the inputs in base of 2.

Ascend

mindspore.mint.logical_and

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

Ascend

mindspore.mint.logical_not

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

Ascend

mindspore.mint.logical_or

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

Ascend

mindspore.mint.logical_xor

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

Ascend

mindspore.mint.mul

Multiply other value by input Tensor.

Ascend

mindspore.mint.mv

Multiply matrix input and vector vec.

Ascend

mindspore.mint.nansum

Computes sum of input over a given dimension, treating NaNs as zero.

Ascend

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

mindspore.mint.neg

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

Ascend

mindspore.mint.negative

Alias for mindspore.mint.neg() .

Ascend

mindspore.mint.pow

Calculates the exponent power of each element in input.

Ascend

mindspore.mint.polar

Converts polar coordinates to Cartesian coordinates.

Ascend

mindspore.mint.ravel

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

Ascend

mindspore.mint.reciprocal

Returns reciprocal of a tensor element-wise.

Ascend

mindspore.mint.remainder

Computes the remainder of input divided by other element-wise.

Ascend

mindspore.mint.roll

Roll the elements of a tensor along a dimension.

Ascend

mindspore.mint.round

Round elements of input to the nearest integer.

Ascend

mindspore.mint.rsqrt

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

Ascend

mindspore.mint.sigmoid

Computes Sigmoid of input element-wise.

Ascend

mindspore.mint.sign

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

Ascend

mindspore.mint.sin

Compute sine of the input tensor element-wise.

Ascend

mindspore.mint.sinc

Compute the normalized sinc of input.

Ascend

mindspore.mint.sinh

Compute hyperbolic sine of the input element-wise.

Ascend

mindspore.mint.softmax

Alias for mindspore.mint.nn.functional.softmax().

Ascend

mindspore.mint.sqrt

Returns sqrt of a tensor element-wise.

Ascend

mindspore.mint.square

Return square of a tensor element-wise.

Ascend

mindspore.mint.sub

Subtracts scaled other value from self Tensor.

Ascend

mindspore.mint.t

Transpose the input tensor.

Ascend

mindspore.mint.tan

Computes tangent of input element-wise.

Ascend

mindspore.mint.tanh

Computes hyperbolic tangent of input element-wise.

Ascend

mindspore.mint.trunc

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

Ascend

mindspore.mint.xlogy

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

Ascend

Reduction Operations

API Name

Description

Supported Platforms

mindspore.mint.amax

Computes the maximum value of of all elements along the specified dim dimension of the input, and retains the dimension based on the keepdim parameter.

Ascend

mindspore.mint.amin

Computes the minimum value of of all elements along the specified dim dimension of the input, and retains the dimension based on the keepdim parameter.

Ascend

mindspore.mint.argmax

Return the indices of the maximum values of a tensor.

Ascend

mindspore.mint.argmin

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

Ascend

mindspore.mint.argsort

Sorts the input tensor along the given dimension in specified order and return the sorted indices.

Ascend

mindspore.mint.all

Tests if all element in input evaluates to True.

Ascend

mindspore.mint.any

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

Ascend

mindspore.mint.cumprod

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

Ascend

mindspore.mint.histc

Computes the histogram of a tensor.

Ascend

mindspore.mint.logsumexp

Computes the logarithm of the sum of exponentiations of all elements along the specified dim dimension of the input (with numerical stabilization), and retains the dimension based on the keepdim parameter.

Ascend

mindspore.mint.max

Returns the maximum value of the input tensor.

Ascend

mindspore.mint.mean

Reduces all dimension of a tensor by averaging all elements.

Ascend

mindspore.mint.median

Output the median on the specified dimension dim and its corresponding index.

Ascend

mindspore.mint.min

Returns the minimum value of the input tensor.

Ascend

mindspore.mint.norm

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

Ascend

mindspore.mint.prod

Multiplying all elements of input.

Ascend

mindspore.mint.sum

Calculate sum of all elements in Tensor.

Ascend

mindspore.mint.std

Calculates the standard deviation over the dimensions specified by dim.

Ascend

mindspore.mint.std_mean

By default, return the standard deviation and mean of each dimension in Tensor.

Ascend

mindspore.mint.unique

Returns the unique elements of input tensor.

Ascend

mindspore.mint.var

Calculates the variance over the dimensions specified by dim.

Ascend

mindspore.mint.var_mean

By default, return the variance and mean of each dimension in Tensor.

Ascend

Comparison Operations

API Name

Description

Supported Platforms

mindspore.mint.allclose

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

Ascend

mindspore.mint.argsort

Sorts the input tensor along the given dimension in specified order and return the sorted indices.

Ascend

mindspore.mint.eq

Compute the equivalence of the two inputs element-wise.

Ascend

mindspore.mint.equal

Computes the equivalence between two tensors.

Ascend

mindspore.mint.greater

Compute the value of input>other element-wise.

Ascend

mindspore.mint.greater_equal

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

Ascend

mindspore.mint.gt

Compute the value of input>other element-wise.

Ascend

mindspore.mint.isclose

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

Ascend

mindspore.mint.isfinite

Determine which elements are finite for each position.

Ascend

mindspore.mint.isinf

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

Ascend

mindspore.mint.isneginf

Determines which elements are -inf for each position.

Ascend

mindspore.mint.le

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

Ascend

mindspore.mint.less

Compute the value of input<other element-wise.

Ascend

mindspore.mint.less_equal

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

Ascend

mindspore.mint.lt

Alias for mindspore.mint.less() .

Ascend

mindspore.mint.maximum

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

Ascend

mindspore.mint.minimum

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

Ascend

mindspore.mint.ne

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

Ascend

mindspore.mint.not_equal

Alias for mindspore.mint.ne() .

Ascend

mindspore.mint.topk

Finds values and indices of the k largest or smallest entries along a given dimension.

Ascend

mindspore.mint.sort

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

Ascend

BLAS and LAPACK Operations

API Name

Description

Supported Platforms

mindspore.mint.addbmm

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

Ascend

mindspore.mint.addmm

Performs a matrix multiplication of the 2-D matrices mat1 and mat2.

Ascend

mindspore.mint.baddbmm

The result is the sum of the input and a batch matrix-matrix product of matrices in batch1 and batch2.

Ascend

mindspore.mint.bmm

Performs batch matrix-matrix multiplication of two three-dimensional tensors.

Ascend

mindspore.mint.dot

Computes the dot product of two 1D tensor.

Ascend

mindspore.mint.inverse

Compute the inverse of the input matrix.

Ascend

mindspore.mint.matmul

Return the matrix product of two tensors.

Ascend

mindspore.mint.meshgrid

Generates coordinate matrices from given coordinate tensors.

Ascend

mindspore.mint.mm

Returns the matrix product of two arrays.

Ascend

mindspore.mint.outer

Return outer product of input and vec2.

Ascend

mindspore.mint.trace

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

Ascend

Other Operations

API Name

Description

Supported Platforms

mindspore.mint.broadcast_to

Broadcasts input tensor to a given shape.

Ascend

mindspore.mint.cdist

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

Ascend

mindspore.mint.cummax

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

Ascend

mindspore.mint.cummin

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

Ascend

mindspore.mint.cumsum

Computes the cumulative sum of input Tensor along dim.

Ascend

mindspore.mint.diag

If input is a vector (1-D tensor), then returns a 2-D square tensor with the elements of input as the diagonal.

Ascend

mindspore.mint.flatten

Flatten a tensor along dimensions from start_dim to end_dim.

Ascend

mindspore.mint.flip

Reverses elements in a tensor along the given dims.

Ascend

mindspore.mint.repeat_interleave

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

Ascend

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

mindspore.mint.tril

Zero the input tensor above the diagonal specified.

Ascend

mindspore.mint.triangular_solve

Solves a system of equations with a square upper or lower triangular invertible matrix A and multiple right-hand sides b.

Ascend

mindspore.mint.nn

Convolution Layers

API Name

Description

Supported Platforms

mindspore.mint.nn.Conv2d

2D convolution layer.

Ascend

mindspore.mint.nn.Conv3d

3D convolution layer.

Ascend

mindspore.mint.nn.ConvTranspose2d

Applies a 2D transposed convolution operator over an input image composed of several input planes.

Ascend

mindspore.mint.nn.Fold

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

Ascend

mindspore.mint.nn.Unfold

Extracts sliding local blocks from a batched input tensor.

Ascend

Normalization Layers

API Name

Description

Supported Platforms

mindspore.mint.nn.BatchNorm1d

Applies Batch Normalization over a 2D or 3D input as described in the paper Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift .

Ascend

mindspore.mint.nn.BatchNorm2d

Applies Batch Normalization over a 4D input as described in the paper Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift .

Ascend

mindspore.mint.nn.BatchNorm3d

Applies Batch Normalization over a 5D input as described in the paper Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift .

Ascend

mindspore.mint.nn.GroupNorm

Group Normalization over a mini-batch of inputs.

Ascend

mindspore.mint.nn.LayerNorm

Applies Layer Normalization over a mini-batch of inputs.

Ascend

mindspore.mint.nn.SyncBatchNorm

Sync Batch Normalization layer over a N-dimension input.

Ascend

Non-linear Activations (weighted sum, nonlinearity)

API Name

Description

Supported Platforms

mindspore.mint.nn.ELU

Exponential Linear Unit activation function

Ascend

mindspore.mint.nn.GELU

Activation function GELU (Gaussian Error Linear Unit).

Ascend

mindspore.mint.nn.GLU

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

Ascend

mindspore.mint.nn.Hardshrink

Applies Hard Shrink activation function element-wise.

Ascend

mindspore.mint.nn.Hardsigmoid

Applies Hard Sigmoid activation function element-wise.

Ascend

mindspore.mint.nn.Hardswish

Applies Hard Swish activation function element-wise.

Ascend

mindspore.mint.nn.LogSigmoid

Applies logsigmoid activation element-wise.

Ascend

mindspore.mint.nn.LogSoftmax

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

Ascend

mindspore.mint.nn.Mish

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

Ascend

mindspore.mint.nn.PReLU

Applies PReLU activation function element-wise.

Ascend

mindspore.mint.nn.ReLU

Applies ReLU (Rectified Linear Unit activation function) element-wise.

Ascend

mindspore.mint.nn.ReLU6

Activation function ReLU6.

Ascend

mindspore.mint.nn.SELU

Activation function SELU (Scaled exponential Linear Unit).

Ascend

mindspore.mint.nn.SiLU

Calculates the SiLU activation function element-wise.

Ascend

mindspore.mint.nn.Sigmoid

Applies sigmoid activation function element-wise.

Ascend

mindspore.mint.nn.Softmax

Applies the Softmax function to an n-dimensional input Tensor.

Ascend

mindspore.mint.nn.Softshrink

Applies the Softshrink function element-wise.

Ascend

mindspore.mint.nn.Tanh

Applies the Tanh function element-wise, returns a new tensor with the hyperbolic tangent of the elements of input.

Ascend

Embedding Layers

API Name

Description

Supported Platforms

mindspore.mint.nn.Embedding

The value in input is used as the index, and the corresponding embedding vector is queried from weight .

Ascend

Linear Layers

API Name

Description

Supported Platforms

mindspore.mint.nn.Linear

The linear connected layer.

Ascend

Dropout Layers

API Name

Description

Supported Platforms

mindspore.mint.nn.Dropout

Dropout layer for the input.

Ascend

mindspore.mint.nn.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

Pooling Layers

API Name

Description

Supported Platforms

mindspore.mint.nn.AdaptiveAvgPool1d

Applies a 1D adaptive average pooling over an input signal composed of several input planes.

Ascend

mindspore.mint.nn.AdaptiveAvgPool2d

Applies a 2D adaptive average pooling over an input signal composed of several input planes.

Ascend

mindspore.mint.nn.AdaptiveAvgPool3d

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

Ascend

mindspore.mint.nn.AdaptiveMaxPool1d

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

Ascend

mindspore.mint.nn.AvgPool2d

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

Ascend

mindspore.mint.nn.AvgPool3d

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

Ascend

mindspore.mint.nn.MaxUnpool2d

Computes the inverse of Maxpool2d.

Ascend

Padding Layers

API Name

Description

Supported Platforms

mindspore.mint.nn.ConstantPad1d

Pad the last dimension of input tensor using padding and value.

Ascend

mindspore.mint.nn.ConstantPad2d

Pad the last 2 dimensions of input tensor using padding and value.

Ascend

mindspore.mint.nn.ConstantPad3d

Pad the last 3 dimension of input tensor using padding and value.

Ascend

mindspore.mint.nn.ReflectionPad1d

Pad the last dimension of input tensor using the reflection of the input boundary.

Ascend

mindspore.mint.nn.ReflectionPad2d

Pad the last 2 dimension of input tensor using the reflection of the input boundary.

Ascend

mindspore.mint.nn.ReflectionPad3d

Pad the last 3 dimension of input tensor using the reflection of the input boundary.

Ascend

mindspore.mint.nn.ReplicationPad1d

Pad the last dimension of input tensor using the replication of the input boundary.

Ascend

mindspore.mint.nn.ReplicationPad2d

Pad the last 2 dimension of input tensor using the replication of the input boundary.

Ascend

mindspore.mint.nn.ReplicationPad3d

Pad the last 3 dimension of input tensor using the replication of the input boundary.

Ascend

mindspore.mint.nn.ZeroPad1d

Pad the last dimension of input tensor with 0 using padding.

Ascend

mindspore.mint.nn.ZeroPad2d

Pad the last 2 dimension of input tensor with 0 using padding.

Ascend

mindspore.mint.nn.ZeroPad3d

Pad the last 3 dimension of input tensor with 0 using padding.

Ascend

Loss Functions

API Name

Description

Supported Platforms

mindspore.mint.nn.BCELoss

Compute the binary cross entropy between the true labels and predicted labels.

Ascend

mindspore.mint.nn.BCEWithLogitsLoss

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

Ascend

mindspore.mint.nn.CrossEntropyLoss

The cross entropy loss between input and target.

Ascend

mindspore.mint.nn.KLDivLoss

Computes the Kullback-Leibler divergence between the input and the target.

Ascend

mindspore.mint.nn.L1Loss

L1Loss is used to calculate the mean absolute error between the predicted value and the target value.

Ascend

mindspore.mint.nn.MSELoss

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

Ascend

mindspore.mint.nn.NLLLoss

Gets the negative log likelihood loss between inputs and target.

Ascend

mindspore.mint.nn.SmoothL1Loss

Computes smooth L1 loss, a robust L1 loss.

Ascend

Vision Layer

API Name

Description

Supported Platforms

mindspore.mint.nn.PixelShuffle

Rearrange elements in a tensor according to an upscaling factor.

Ascend

mindspore.mint.nn.Upsample

For details, please refer to mindspore.mint.nn.functional.interpolate().

Ascend

Tools

API Name

Description

Supported Platforms

mindspore.mint.nn.Identity

A placeholder identity operator that returns the same as input.

Ascend

mindspore.mint.nn.functional

Convolution functions

API Name

Description

Supported Platforms

mindspore.mint.nn.functional.conv2d

Applies a 2D convolution over an input tensor.

Ascend

mindspore.mint.nn.functional.conv3d

Applies a 3D convolution over an input tensor.

Ascend

mindspore.mint.nn.functional.conv_transpose2d

Applies a 2D transposed convolution operator over an input image composed of several input planes, sometimes also called deconvolution (although it is not an actual deconvolution).

Ascend

mindspore.mint.nn.functional.fold

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

Ascend

mindspore.mint.nn.functional.unfold

Extracts sliding local blocks from a batched input tensor.

Ascend

Pooling functions

API Name

Description

Supported Platforms

mindspore.mint.nn.functional.adaptive_avg_pool1d

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

Ascend

mindspore.mint.nn.functional.adaptive_avg_pool2d

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

Ascend

mindspore.mint.nn.functional.adaptive_avg_pool3d

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

Ascend

mindspore.mint.nn.functional.adaptive_max_pool1d

Performs 1D adaptive max pooling on a multi-plane input signal.

Ascend

mindspore.mint.nn.functional.avg_pool1d

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

Ascend

mindspore.mint.nn.functional.avg_pool2d

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

Ascend

mindspore.mint.nn.functional.avg_pool3d

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

Ascend

mindspore.mint.nn.functional.max_pool2d

Performs a 2D max pooling on the input Tensor.

Ascend

mindspore.mint.nn.functional.max_unpool2d

Computes the inverse of max_pool2d.

Ascend

Non-linear activation functions

API Name

Description

Supported Platforms

mindspore.mint.nn.functional.batch_norm

Batch Normalization for input data and updated parameters.

Ascend

mindspore.mint.nn.functional.elu

Exponential Linear Unit activation function

Ascend

mindspore.mint.nn.functional.elu_

Exponential Linear Unit activation function

Ascend

mindspore.mint.nn.functional.gelu

Gaussian Error Linear Units activation function.

Ascend

mindspore.mint.nn.functional.glu

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

Ascend

mindspore.mint.nn.functional.group_norm

Group Normalization over a mini-batch of inputs.

Ascend

mindspore.mint.nn.functional.hardshrink

Hard Shrink activation function.

Ascend

mindspore.mint.nn.functional.hardsigmoid

Hard Sigmoid activation function.

Ascend

mindspore.mint.nn.functional.hardswish

Hard Swish activation function.

Ascend

mindspore.mint.nn.functional.layer_norm

Applies the Layer Normalization on the mini-batch input.

Ascend

mindspore.mint.nn.functional.leaky_relu

leaky_relu activation function.

Ascend

mindspore.mint.nn.functional.log_softmax

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

Ascend

mindspore.mint.nn.functional.logsigmoid

Applies logsigmoid activation element-wise.

Ascend

mindspore.mint.nn.functional.mish

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

Ascend

mindspore.mint.nn.functional.prelu

Parametric Rectified Linear Unit activation function.

Ascend

mindspore.mint.nn.functional.relu

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

Ascend

mindspore.mint.nn.functional.relu6

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

Ascend

mindspore.mint.nn.functional.relu_

ReLuComputes ReLU (Rectified Linear Unit activation function) inplace of input tensors element-wise.

Ascend

mindspore.mint.nn.functional.selu

Activation function SELU (Scaled exponential Linear Unit).

Ascend

mindspore.mint.nn.functional.sigmoid

Computes Sigmoid of input element-wise.

Ascend

mindspore.mint.nn.functional.silu

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

Ascend

mindspore.mint.nn.functional.softmax

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

Ascend

mindspore.mint.nn.functional.softplus

Applies softplus function to input element-wise.

Ascend

mindspore.mint.nn.functional.softshrink

Soft Shrink activation function.

Ascend

mindspore.mint.nn.functional.tanh

Computes hyperbolic tangent of input element-wise.

Ascend

Normalization functions

API Name

Description

Supported Platforms

mindspore.mint.nn.functional.normalize

Perform normalization of inputs over specified dimension

Ascend

Linear functions

API Name

Description

Supported Platforms

mindspore.mint.nn.functional.linear

Applies the dense connected operation to the input.

Ascend

Dropout functions

API Name

Description

Supported Platforms

mindspore.mint.nn.functional.dropout

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

Ascend

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

Ascend

Sparse functions

API Name

Description

Supported Platforms

mindspore.mint.nn.functional.embedding

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

Ascend

mindspore.mint.nn.functional.one_hot

Computes a one-hot tensor.

Ascend

Loss Functions

API Name

Description

Supported Platforms

mindspore.mint.nn.functional.cross_entropy

The cross entropy loss between input and target.

Ascend

mindspore.mint.nn.functional.binary_cross_entropy

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

Ascend

mindspore.mint.nn.functional.binary_cross_entropy_with_logits

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

Ascend

mindspore.mint.nn.functional.kl_div

Computes the Kullback-Leibler divergence between the input and the target.

Ascend

mindspore.mint.nn.functional.l1_loss

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

Ascend

mindspore.mint.nn.functional.mse_loss

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

Ascend

mindspore.mint.nn.functional.nll_loss

Gets the negative log likelihood loss between input and target.

Ascend

mindspore.mint.nn.functional.smooth_l1_loss

Computes smooth L1 loss, a robust L1 loss.

Ascend

Vision functions

API Name

Description

Supported Platforms

mindspore.mint.nn.functional.interpolate

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

Ascend

mindspore.mint.nn.functional.grid_sample

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

Ascend

mindspore.mint.nn.functional.pad

Pads the input tensor according to the pad.

Ascend

mindspore.mint.nn.functional.pixel_shuffle

Rearrange elements in a tensor according to an upscaling factor.

Ascend

mindspore.mint.optim

API Name

Description

Supported Platforms

mindspore.mint.optim.Adam

Implements Adaptive Moment Estimation (Adam) algorithm.

Ascend

mindspore.mint.optim.AdamW

Implements Adam Weight Decay algorithm.

Ascend

mindspore.mint.optim.SGD

Stochastic Gradient Descent optimizer.

Ascend

mindspore.mint.linalg

Inverses

API Name

Description

Supported Platforms

mindspore.mint.linalg.inv

Compute the inverse of the input matrix.

Ascend

mindspore.mint.linalg.matrix_norm

Returns the matrix norm of a given tensor on the specified dimensions.

Ascend

mindspore.mint.linalg.norm

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

Ascend

mindspore.mint.linalg.vector_norm

Returns the vector norm of the given tensor on the specified dimensions.

Ascend

mindspore.mint.linalg.qr

Orthogonal decomposition of the input A=QR.

Ascend

mindspore.mint.special

Pointwise Operations

API Name

Description

Supported Platforms

mindspore.mint.special.erfc

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

Ascend

mindspore.mint.special.exp2

Calculates the base-2 exponent of the Tensor input element by element.

Ascend

mindspore.mint.special.expm1

Compute exponential of the input tensor, then minus 1, element-wise.

Ascend

mindspore.mint.special.log1p

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

Ascend

mindspore.mint.special.log_softmax

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

Ascend

mindspore.mint.special.round

Returns half to even of a tensor element-wise.

Ascend

mindspore.mint.special.sinc

Compute the normalized sinc of input.

Ascend

mindspore.mint.distributed

API Name

Description

Supported Platforms

mindspore.mint.distributed.all_gather

Gathers tensors from the specified communication group and returns the tensor list which is all gathered.

Ascend

mindspore.mint.distributed.all_gather_into_tensor

Gathers tensors from the specified communication group and returns the tensor which is all gathered.

Ascend

mindspore.mint.distributed.all_gather_object

Aggregates Python objects in a specified communication group.

Ascend

mindspore.mint.distributed.all_reduce

Reduce tensors across all devices in such a way that all deviceswill get the same final result, returns the tensor which is all reduced.

Ascend

mindspore.mint.distributed.all_to_all

scatter and gather list of tensor to/from all rank according to input/output tensor list.

Ascend

mindspore.mint.distributed.all_to_all_single

scatter and gather input with split size to/from all rank, and return result in a single tensor.

Ascend

mindspore.mint.distributed.barrier

Synchronizes all processes in the specified group.

Ascend

mindspore.mint.distributed.batch_isend_irecv

Batch send and recv tensors asynchronously.

Ascend

mindspore.mint.distributed.broadcast

Broadcasts the tensor to the whole group.

Ascend

mindspore.mint.distributed.broadcast_object_list

Broadcasts the entire group of input Python objects.

Ascend

mindspore.mint.distributed.destroy_process_group

Destroy the user collective communication group.

Ascend

mindspore.mint.distributed.gather

Gathers tensors from the specified communication group.

Ascend

mindspore.mint.distributed.gather_object

Gathers python objects from the whole group in a single process.

Ascend

mindspore.mint.distributed.get_backend

Get the backend of communication process groups.

Ascend

mindspore.mint.distributed.get_global_rank

A function that returns the rank id in the world group corresponding to the rank which id is 'group_rank' in the user group.

Ascend

mindspore.mint.distributed.get_group_rank

Get the rank ID in the specified user communication group corresponding to the rank ID in the world communication group.

Ascend

mindspore.mint.distributed.get_process_group_ranks

Gets the ranks of the specific group and returns the process ranks in the communication group as a list.

Ascend

mindspore.mint.distributed.get_rank

Get the rank ID for the current device in the specified collective communication group.

Ascend

mindspore.mint.distributed.get_world_size

Get the rank size of the specified collective communication group.

Ascend

mindspore.mint.distributed.init_process_group

Init collective communication lib.

Ascend

mindspore.mint.distributed.irecv

Receive tensors from src asynchronously.

Ascend

mindspore.mint.distributed.isend

Send tensors to the specified dest_rank asynchronously.

Ascend

mindspore.mint.distributed.is_available

Checks if distributed module is available.

Ascend

mindspore.mint.distributed.is_initialized

Checks if default process group has been initialized.

Ascend

mindspore.mint.distributed.new_group

Create a new distributed group.

Ascend

mindspore.mint.distributed.P2POp

Object for batch_isend_irecv input, to store information of "isend" and "irecv".

Ascend

mindspore.mint.distributed.recv

Receive tensors from src.

Ascend

mindspore.mint.distributed.reduce

Reduces tensors across the processes in the specified communication group, sends the result to the target dst(global rank), and returns the tensor which is sent to the target process.

Ascend

mindspore.mint.distributed.reduce_scatter

Reduces and scatters tensors from the specified communication group and returns the tensor which is reduced and scattered.

Ascend

mindspore.mint.distributed.reduce_scatter_tensor

Reduces and scatters tensors from the specified communication group and returns the tensor which is reduced and scattered.

Ascend

mindspore.mint.distributed.scatter

Scatter tensor evently across the processes in the specified communication group.

Ascend

mindspore.mint.distributed.scatter_object_list

Scatters picklable objects in scatter_object_input_list to the whole group.

Ascend

mindspore.mint.distributed.send

Send tensors to the specified dest_rank.

Ascend