mindspore.ops.function
Compared with the previous version, the added, deleted and supported platforms change information of mindspore.ops.function operators in MindSpore, please refer to the link mindspore.ops.function API Interface Change.
Neural Network Layer Functions
Neural Network
API Name |
Description |
Supported Platforms |
This operator applies a 2D adaptive average pooling to an input signal composed of multiple input planes. |
|
|
This operator applies a 3D adaptive average pooling to an input signal composed of multiple input planes. |
|
|
adaptive_max_pool2d operation. |
|
|
Average pooling operation. |
|
|
Returns the sum of the input_x and the bias Tensor. |
|
|
Applies a 2D convolution over an input tensor. |
|
|
Performs greedy decoding on the logits given in inputs. |
|
|
Given 4D tensor inputs x, weight and offsets, compute a 2D deformable convolution. |
|
|
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\)). |
|
|
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\)). |
|
|
Flattens a tensor without changing its batch size on the 0-th axis. |
|
|
Using the interpolate method specified by mode resize the input tensor x. |
|
|
Local Response Normalization. |
|
|
Performs a 3D max pooling on the input Tensor. |
|
|
Computes the Kullback-Leibler divergence between the logits and the labels. |
|
|
Pads the input tensor according to the paddings. |
|
|
Extends the last dimension of the input tensor from 1 to pad_dim_size, by filling with 0. |
|
Loss Functions
API Name |
Description |
Supported Platforms |
Adds sigmoid activation function to input logits, and uses the given logits to compute binary cross entropy between the logits and the label. |
|
|
The cross entropy loss between input and target. |
|
|
Gets the negative log likelihood loss between inputs and target. |
|
|
Computes smooth L1 loss, a robust L1 loss. |
|
Activation Functions
API Name |
Description |
Supported Platforms |
During training, randomly zeroes some of the elements of the input tensor with probability p from a Bernoulli distribution. |
|
|
Fast Gaussian Error Linear Units activation function. |
|
|
Returns the samples from the Gumbel-Softmax distribution and optionally discretizes. |
|
|
Hard Shrink activation function. |
|
|
Applies hswish-type activation element-wise. |
|
|
Applies the Log Softmax function to the input tensor on the specified axis. |
|
|
Computes MISH(A Self Regularized Non-Monotonic Neural Activation Function) of input tensors element-wise. |
|
|
Activation function SeLU (Scaled exponential Linear Unit). |
|
|
Computes Sigmoid of input element-wise. |
|
|
Softsign activation function. |
|
|
Applies the SoftShrink function element-wise. |
|
|
Applies the Softmax operation to the input tensor on the specified axis. |
|
|
Computes hyperbolic tangent of input element-wise. |
|
Sampling Functions
API Name |
Description |
Supported Platforms |
Given an input_x and a flow-field grid, computes the output using input_x values and pixel locations from grid. |
|
|
Uniform candidate sampler. |
|
Distance Functions
API Name |
Description |
Supported Platforms |
Computes batched the p-norm distance between each pair of the two collections of row vectors. |
|
Image Functions
API Name |
Description |
Supported Platforms |
Calculates intersection over union for boxes. |
|
Element-by-Element Operations
API Name |
Description |
Supported Platforms |
Returns absolute value of a tensor element-wise. |
|
|
Computes arccosine of input tensors element-wise. |
|
|
Computes inverse hyperbolic cosine of the inputs element-wise. |
|
|
Adds two input tensors element-wise. |
|
|
Performs the element-wise division of tensor x1 by tensor x2, multiply the result by the scalar value and add it to input_data. |
|
|
Performs the element-wise product of tensor x1 and tensor x2, multiply the result by the scalar value and add it to input_data. |
|
|
Computes addition of all input tensors element-wise. |
|
|
Computes arcsine of input tensors element-wise. |
|
|
Computes inverse hyperbolic sine of the input element-wise. |
|
|
Computes the trigonometric inverse tangent of the input element-wise. |
|
|
Returns arctangent of x/y element-wise. |
|
|
Computes inverse hyperbolic tangent of the input element-wise. |
|
|
Randomly set the elements of output to 0 or 1 with the probability of P which follows the Bernoulli distribution. |
|
|
Computes the Bessel i0 function of x element-wise. |
|
|
Computes the Bessel i0e function of x element-wise. |
|
|
Computes the Bessel i1 function of x element-wise. |
|
|
Computes the Bessel i1e function of x element-wise. |
|
|
Computes the Bessel j0 function of x element-wise. |
|
|
Computes the Bessel j1 function of x element-wise. |
|
|
Computes the Bessel k0 function of x element-wise. |
|
|
Computes the Bessel k0e function of x element-wise. |
|
|
Computes the Bessel k1 function of x element-wise. |
|
|
Computes the Bessel k1e function of x element-wise. |
|
|
Computes the Bessel y0 function of x element-wise. |
|
|
Computes the Bessel y1 function of x element-wise. |
|
|
Returns bitwise and of two tensors element-wise. |
|
|
Returns bitwise or of two tensors element-wise. |
|
|
Returns bitwise xor of two tensors element-wise. |
|
|
Rounds a tensor up to the closest integer element-wise. |
|
|
Computes cosine of input element-wise. |
|
|
Computes hyperbolic cosine of input element-wise. |
|
|
Divides the first input tensor by the second input tensor in floating-point type element-wise. |
|
|
Computes the Gauss error function of x element-wise. |
|
|
Computes the complementary error function of x element-wise. |
|
|
Returns exponential of a tensor element-wise. |
|
|
Returns exponential then minus 1 of a tensor element-wise. |
|
|
Rounds a tensor down to the closest integer element-wise. |
|
|
Divides the first input tensor by the second input tensor element-wise and round down to the closest integer. |
|
|
Computes the remainder of division element-wise. |
|
|
Computes Reciprocal of input tensor element-wise. |
|
|
Flips all bits of input tensor element-wise. |
|
|
Does a linear interpolation of two tensors start and end based on a float or tensor weight. |
|
|
Returns the natural logarithm of a tensor element-wise. |
|
|
Returns the natural logarithm of one plus the input tensor element-wise. |
|
|
Computes the "logical AND" of two tensors element-wise. |
|
|
Computes the "logical NOT" of a tensor element-wise. |
|
|
Computes the "logical OR" of two tensors element-wise. |
|
|
Multiplies two tensors element-wise. |
|
|
Returns a tensor with negative values of the input tensor element-wise. |
|
|
Calculates the y power of each element in x. |
|
|
Returns half to even of a tensor element-wise. |
|
|
Computes sine of the input element-wise. |
|
|
Computes hyperbolic sine of the input element-wise. |
|
|
Returns square of a tensor element-wise. |
|
|
Subtracts the second input tensor from the first input tensor element-wise. |
|
|
Computes tangent of x element-wise. |
|
|
Returns a new tensor with the truncated integer values of the elements of input. |
|
|
Divides the first input tensor by the second input tensor element-wise for integer types, negative numbers will round fractional quantities towards zero. |
|
|
Returns the remainder of division element-wise. |
|
|
Divides the first input tensor by the second input tensor element-wise. |
|
|
Computes the first input tensor multiplied by the logarithm of second input tensor element-wise. |
|
Reduction Functions
API Name |
Description |
Supported Platforms |
Reduces a dimension of a tensor by the maximum value in this dimension, by default. |
|
|
Reduces a dimension of a tensor by the minimum value in the dimension, by default. |
|
|
Returns the indices of the minimum value of a tensor across the axis. |
|
|
Returns a tuple (values,indices) where 'values' is the cumulative maximum value of input Tensor x along the dimension axis, and indices is the index location of each maximum value. |
|
|
Returns a tuple (values,indices) where 'values' is the cumulative minimum value of input Tensor x along the dimension axis, and indices is the index location of each minimum value. |
|
|
Reduces a dimension of a tensor by calculating exponential for all elements in the dimension, then calculate logarithm of the sum. |
|
|
Calculates the maximum value with the corresponding index. |
|
|
Reduces a dimension of a tensor by averaging all elements in the dimension, by default. |
|
|
Calculates the minimum value along with the given axis for the input tensor. |
|
|
Returns the matrix norm or vector norm of a given tensor. |
|
|
Reduces a dimension of a tensor by multiplying all elements in the dimension, by default. |
|
|
Returns the standard-deviation and mean of each row of the input tensor in the dimension axis. |
|
function |
Description |
---|---|
mindspore.ops.reduce_sum |
Refer to |
Comparison Functions
API Name |
Description |
Supported Platforms |
Returns True if abs(x-y) is smaller than tolerance element-wise, otherwise False. |
|
|
Computes the equivalence between two tensors element-wise. |
|
|
Computes the boolean value of \(x >= y\) element-wise. |
|
|
Compare the value of the input parameters \(x,y\) element-wise, and the output result is a bool value. |
|
|
Determines whether the targets are in the top k predictions. |
|
|
Returns a new Tensor with boolean elements representing if each element of x1 is “close” to the corresponding element of x2. |
|
|
Determines which elements are finite for each position. |
|
|
Determines which elements are NaN for each position. |
|
|
Computes the boolean value of \(x <= y\) element-wise. |
|
|
Computes the boolean value of \(x < y\) element-wise. |
|
|
Computes the maximum of input tensors element-wise. |
|
|
Computes the minimum of input tensors element-wise. |
|
|
Computes the non-equivalence of two tensors element-wise. |
|
|
Checks whether the data type and shape of two tensors are the same. |
|
function |
Description |
---|---|
mindspore.ops.check_bprop |
Refer to |
mindspore.ops.isinstance_ |
Refer to |
mindspore.ops.issubclass_ |
Refer to |
Linear Algebraic Functions
API Name |
Description |
Supported Platforms |
Computation of batch dot product between samples in two tensors containing batch dims. |
|
|
Computation a dot product between samples in two tensors. |
|
|
Returns the matrix product of two tensors. |
|
|
Solves systems of linear equations. |
|
|
Ger product of x1 and x2. |
|
|
Renormalizes the sub-tensors along dimension dim, and each sub-tensor's p-norm should not exceed the 'maxnorm'. |
|
|
Computation of Tensor contraction on arbitrary axes between tensors a and b. |
|
Tensor Operation Functions
Tensor Building
API Name |
Description |
Supported Platforms |
Creates a tensor with ones on the diagonal and zeros in the rest. |
|
|
Create a Tensor of the specified shape and fill it with the specified value. |
|
|
Returns a Tensor whose value is num evenly spaced in the interval start and stop (including start and stop), and the length of the output Tensor is num. |
|
|
Returns a narrowed tensor from input tensor. |
|
|
Computes a one-hot tensor. |
|
|
Creates a tensor filled with value ones. |
|
|
Returns a Tensor with a value of 1 and its shape and data type is the same as the input. |
|
Randomly Generating Functions
API Name |
Description |
Supported Platforms |
Generates random numbers according to the Gamma random number distribution. |
|
|
Generates random numbers according to the Laplace random number distribution. |
|
|
Returns a tensor sampled from the multinomial probability distribution located in the corresponding row of the input tensor. |
|
|
The ops.poisson is deprecated, please use |
deprecated |
|
Generates random numbers according to the Poisson random number distribution. |
|
|
Generates random samples from a given categorical distribution tensor. |
|
|
Outputs random values from the Gamma distribution(s) described by alpha. |
|
|
Generates random numbers according to the Laplace random number distribution (mean=0, lambda=1). |
|
|
Generates random numbers according to the standard Normal (or Gaussian) random number distribution. |
|
|
Generates random numbers according to the Uniform random number distribution. |
|
Array Operation
API Name |
Description |
Supported Platforms |
Divides batch dimension with blocks and interleaves these blocks back into spatial dimensions. |
|
|
Broadcasts input tensor to a given shape. |
|
|
Combines an array of sliding local blocks into a large containing tensor. |
|
|
Connect tensor in the specified axis. |
|
|
Count number of nonzero elements across axis of input tensor |
|
|
Constructs a diagonal tensor with a given diagonal values. |
|
|
Adds an additional dimension to input_x at the given axis. |
|
|
Returns the slice of the input tensor corresponding to the elements of input_indices on the specified axis. |
|
|
Gathers elements along an axis specified by dim. |
|
|
Gathers elements along an axis specified by dim. |
|
|
Gathers slices from a tensor by indices. |
|
|
Adds tensor y to specified axis and indices of Parameter x. |
|
|
Fills the elements under the dim dimension of the input Tensor x with the input value by selecting the indices in the order given in index. |
|
|
Adds v into specified rows of x. |
|
|
Subtracts v into specified rows of x. |
|
|
Updates specified rows with values in v. |
|
|
Fills elements of Tensor with value where mask is True. |
|
|
Returns a new 1-D Tensor which indexes the x tensor according to the boolean mask. |
|
|
Copy a tensor setting everything outside a central band in each innermost matrix to zero. |
|
|
Returns a Tensor with the contents in x as k[0]-th to k[1]-th diagonals of a matrix, with everything else padded with padding_value. |
|
|
Returns the diagonal part of input tensor. |
|
|
Returns a batched matrix tensor with new batched diagonal values. |
|
|
Generates coordinate matrices from given coordinate tensors. |
|
|
Generates random numbers according to the Normal (or Gaussian) random number distribution. |
|
|
Return a Tensor of the positions of all non-zero values. |
GPU` |
|
Computes element-wise population count(a.k.a bitsum, bitcount). |
|
|
Creates a sequence of numbers that begins at start and extends by increments of delta up to but not including limit. |
|
|
Returns the rank of a tensor. |
|
|
Repeat elements of a tensor along an axis, like np.repeat . |
|
|
Rearranges the input Tensor based on the given shape. |
|
|
Reverses variable length slices. |
|
|
Scatters a tensor into a new tensor depending on the specified indices. |
|
|
The conditional tensor determines whether the corresponding element in the output must be selected from \(x\) (if true) or \(y\) (if false) based on the value of each element. |
|
|
Returns a mask tensor representing the first N positions of each cell. |
|
|
Returns the shape of the input tensor. |
|
|
Returns a Scalar of type int that represents the size of the input Tensor and the total number of elements in the Tensor. |
|
|
Slices a tensor in the specified shape. |
|
|
Divides a tensor's spatial dimensions into blocks and combines the block sizes with the original batch. |
|
|
Computes a Tensor such that \(output_i = \frac{\sum_j x_{indices[j]}}{N}\) where mean is over \(j\) such that \(segment\_ids[j] == i\) and \(N\) is the total number of values summed. |
|
|
Splits the input tensor into output_num of tensors along the given axis and output numbers. |
|
|
Return the Tensor after deleting the dimension of size 1 in the specified axis. |
|
|
Stacks a list of tensors in specified axis. |
|
|
Creates a new tensor by adding the values from the positions in input_x indicated by indices, with values from updates. |
|
|
Creates a new tensor by dividing the values from the positions in input_x indicated by indices, with values from updates. |
|
|
Creates a new tensor by multiplying the values from the positions in input_x indicated by indices, with values from updates. |
|
|
Creates a new tensor by subtracting the values from the positions in input_x indicated by indices, with values from updates. |
|
|
Updates the value of the input tensor through the reduction operation. |
|
|
Replicates an input tensor with given multiples times. |
|
|
Finds values and indices of the k largest entries along the last dimension. |
|
|
Permutes the dimensions of the input tensor according to input permutation. |
|
|
Returns the unique elements of input tensor and also return a tensor containing the index of each value of input tensor corresponding to the output unique tensor. |
|
|
Returns the elements that are unique in each consecutive group of equivalent elements in the input tensor. |
|
|
Returns unique elements and relative indexes in 1-D tensor, filled with padding num. |
|
|
Computes the maximum along segments of a tensor. |
|
|
Computes the minimum of a tensor along segments. |
|
|
Computes the product of a tensor along segments. |
|
|
Computes the sum of a tensor along segments. |
|
|
Unstacks tensor in specified axis. |
|
function |
Description |
---|---|
mindspore.ops.cast |
Refer to |
mindspore.ops.cumprod |
Refer to |
mindspore.ops.cumsum |
Refer to |
mindspore.ops.dtype |
Refer to |
mindspore.ops.sort |
Refer to |
mindspore.ops.strided_slice |
Refer to |
mindspore.ops.tensor_scatter_update |
Refer to |
Type Conversion
API Name |
Description |
Supported Platforms |
Casts the input scalar to another type. |
|
|
Converts a scalar to a Tensor. |
|
|
Converts a scalar to a Tensor, and converts the data type to the specified type. |
|
|
Converts a tuple to a tensor. |
|
Sparse Functions
API Name |
Description |
Supported Platforms |
Convert a Tensor to COOTensor. |
|
|
Convert a Tensor to CSRTensor. |
|
|
Converts a CSRTensor to COOTensor. |
|
Gradient Clipping
API Name |
Description |
Supported Platforms |
Clips tensor values by the ratio of the sum of their norms. |
|
|
Clips tensor values to a specified min and max. |
|
Parameter Operation Functions
API Name |
Description |
Supported Platforms |
Assigns Parameter with a value. |
|
|
Updates a Parameter by adding a value to it. |
|
|
Updates a Parameter by subtracting a value from it. |
|
|
Using given values to update tensor value through the add operation, along with the input indices. |
|
|
Using given values to update tensor value through the div operation, along with the input indices. |
|
|
Using given values to update tensor value through the min operation, along with the input indices. |
|
|
Using given values to update tensor value through the max operation, along with the input indices. |
|
|
Updates the value of the input tensor through the multiply operation. |
|
|
Applies sparse addition to individual values or slices in a tensor. |
|
|
Applying sparse division to individual values or slices in a tensor. |
|
|
Applying sparse maximum to individual values or slices in a tensor. |
|
|
Applying sparse minimum to individual values or slices in a tensor. |
|
|
Applies sparse multiplication to individual values or slices in a tensor. |
|
|
Applies sparse subtraction to individual values or slices in a tensor. |
|
|
Updates tensor values by using input indices and value. |
|
Differential Functions
API Name |
Description |
Supported Platforms |
This function is designed to calculate the higher order differentiation of given composite function. |
|
|
A wrapper function to generate the gradient function for the input function. |
|
|
A wrapper function to generate the function to calculate forward output and gradient for the input function. |
|
|
This function is designed to calculate the higher order differentiation of given composite function. |
|
|
Compute the jacobian-vector-product of the given network. |
|
|
Compute the vector-jacobian-product of the given network. |
|
|
Vectorizing map (vmap) is a kind of higher-order function to map fn along the parameter axes. |
|
Other Functions
function |
Description |
---|---|
mindspore.ops.bool_and |
Calculate the result of logical AND operation. (Usage is the same as “and” in Python) |
mindspore.ops.bool_eq |
Determine whether the Boolean values are equal. (Usage is the same as “==” in Python) |
mindspore.ops.bool_not |
Calculate the result of logical NOT operation. (Usage is the same as “not” in Python) |
mindspore.ops.bool_or |
Calculate the result of logical OR operation. (Usage is the same as “or” in Python) |
mindspore.ops.depend |
Refer to |
mindspore.ops.in_dict |
Determine if a str in dict. |
mindspore.ops.is_not |
Determine whether the input is not the same as the other one. (Usage is the same as “is not” in Python) |
mindspore.ops.is_ |
Determine whether the input is the same as the other one. (Usage is the same as “is” in Python) |
mindspore.ops.isconstant |
Determine whether the object is constant. |
mindspore.ops.not_in_dict |
Determine whether the object is not in the dict. |
mindspore.ops.partial |
Refer to |
mindspore.ops.scalar_add |
Get the sum of two numbers. (Usage is the same as “+” in Python) |
mindspore.ops.scalar_div |
Get the quotient of dividing the first input number by the second input number. (Usage is the same as “/” in Python) |
mindspore.ops.scalar_eq |
Determine whether two numbers are equal. (Usage is the same as “==” in Python) |
mindspore.ops.scalar_floordiv |
Divide the first input number by the second input number and round down to the closest integer. (Usage is the same as “//” in Python) |
mindspore.ops.scalar_ge |
Determine whether the number is greater than or equal to another number. (Usage is the same as “>=” in Python) |
mindspore.ops.scalar_gt |
Determine whether the number is greater than another number. (Usage is the same as “>” in Python) |
mindspore.ops.scalar_le |
Determine whether the number is less than or equal to another number. (Usage is the same as “<=” in Python) |
mindspore.ops.scalar_log |
Get the natural logarithm of the input number. |
mindspore.ops.scalar_lt |
Determine whether the number is less than another number. (Usage is the same as “<” in Python) |
mindspore.ops.scalar_mod |
Get the remainder of dividing the first input number by the second input number. (Usage is the same as “%” in Python) |
mindspore.ops.scalar_mul |
Get the product of the input two numbers. (Usage is the same as “*” in Python) |
mindspore.ops.scalar_ne |
Determine whether two numbers are not equal. (Usage is the same as “!=” in Python) |
mindspore.ops.scalar_pow |
Compute a number to the power of the second input number. |
mindspore.ops.scalar_sub |
Subtract the second input number from the first input number. (Usage is the same as “-” in Python) |
mindspore.ops.scalar_uadd |
Get the positive value of the input number. |
mindspore.ops.scalar_usub |
Get the negative value of the input number. |
mindspore.ops.shape_mul |
The input of shape_mul must be shape multiply elements in tuple(shape). |
mindspore.ops.stop_gradient |
Disable update during back propagation. (stop_gradient) |
mindspore.ops.string_concat |
Concatenate two strings. |
mindspore.ops.string_eq |
Determine if two strings are equal. |
mindspore.ops.typeof |
Get type of object. |
API Name |
Description |
Supported Platforms |
A decorator that adds a flag to the function. |
|