mindspore.ops.fmod
- mindspore.ops.fmod(input, other)[source]
Compute the remainder of element-wise division of first input by the second input.
Support broadcasting and type promotion.
Where
is with its fractional part truncated. The returned value has the same sign as input and is less than other in magnitude.- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> # case 1: When other is scalar: >>> input = mindspore.tensor([-3., -2, -1, 3, 4, 5]) >>> output = mindspore.ops.fmod(input, 2) >>> print(output) [-1. 0. -1. 1. 0. 1.] >>> >>> # case 2: When other is a tensor: >>> other = mindspore.tensor([-1., 1, 2, 2.5, 1.5, 1.7]) >>> output = mindspore.ops.fmod(input, other) >>> print(output) [ 0. 0. -1. 0.5 1. 1.5999999]