mindspore.ops.remainder

View Source On Gitee
mindspore.ops.remainder(input, other)[source]

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

Support implicit type conversion and type promotion.

remainder(input, other) == input - input.div(other, rounding_mode="floor") * other

Warning

  • When the elements of input exceed 2048, there might be accuracy problems.

  • The calculation results of this operator on Ascend and CPU might be inconsistent.

  • If shape is expressed as (D1,D2… ,Dn), then D1*D2… *DN<=1000000,n<=8.

Parameters
Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> # case 1: The shape of two inputs are different
>>> x = mindspore.tensor([-4.0, 5.0, 6.0], mindspore.float16)
>>> y = mindspore.tensor([3.0], mindspore.float16)
>>> output = mindspore.ops.remainder(x, y)
>>> print(output)
[2. 2. 0.]
>>> # case 2: The shape of two inputs are the same
>>> x = mindspore.tensor([-4.0, 5.0, 6.0], mindspore.float16)
>>> y = mindspore.tensor([3.0, 2.0, 3.0], mindspore.float16)
>>> output = mindspore.ops.remainder(x, y)
>>> print(output)
[2. 1. 0.]