mindspore.ops.fmod

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

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

\[out = input - n * other\]

Where \(n\) is \(input/other\) with its fractional part truncated. The returned value has the same sign as input and is less than other in magnitude.

Parameters
  • input (Union[Tensor, Number]) – the dividend.

  • other (Union[Tensor, Number]) – the divisor.

Returns

Tensor, the shape is the same as the one after broadcasting, and the data type is the one with higher precision or higher digits among the two inputs.

Raises

TypeError – If neither input nor other is a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input = Tensor(np.array([-4., -3.5, 0, 3.5, 4]), mindspore.float32)
>>> output = ops.fmod(input, 2.5)
>>> print(output)
[-1.5 -1.   0.   1.   1.5]