Mod¶
Mod - 13¶
Version¶
name: Mod (GitHub)
domain:
main
since_version:
13
function:
False
support_level:
SupportType.COMMON
shape inference:
True
This version of the operator has been available since version 13.
Summary¶
Performs an element-wise binary modulo operation.
The semantics and supported data types depend on the value of the fmod
attribute which must be 0
(default), or 1
.
If the fmod
attribute is set to 0
, T
is constrained to integer data types and the semantics follow that of the Python %
-operator.
The sign of the result is that of the divisor.
If fmod
is set to 1
, the behavior of this operator follows that of the fmod
function in C and T
is constrained to floating point data types.
The result of this operator is the remainder of the division operation x / y
where x
and y
are respective elements of A
and B
. The result is exactly the value x - n * y
, where n
is x / y
with its fractional part truncated.
The returned value has the same sign as x
(except if x
is -0
) and is less or equal to |y|
in magnitude.
The following special cases apply when fmod
is set to 1
:
If
x
is-0
andy
is greater than zero, either+0
or-0
may be returned.If
x
is±∞
andy
is notNaN
,NaN
is returned.If
y
is±0
andx
is notNaN
,NaN
should be returned.If
y
is±∞
andx
is finite,x
is returned.If either argument is
NaN
,NaN
is returned.
This operator supports multidirectional (i.e., NumPy-style) broadcasting; for more details please check Broadcasting in ONNX.
Attributes¶
fmod - INT (default is
'0'
):Whether the operator should behave like fmod (default=0 meaning it will do integer mods); Set this to 1 to force fmod treatment
Inputs¶
A (heterogeneous) - T:
Dividend tensor
B (heterogeneous) - T:
Divisor tensor
Outputs¶
C (heterogeneous) - T:
Remainder tensor
Type Constraints¶
T in (
tensor(bfloat16)
,tensor(double)
,tensor(float)
,tensor(float16)
,tensor(int16)
,tensor(int32)
,tensor(int64)
,tensor(int8)
,tensor(uint16)
,tensor(uint32)
,tensor(uint64)
,tensor(uint8)
):Constrain input and output types to high-precision numeric tensors.
Mod - 10¶
Version¶
name: Mod (GitHub)
domain:
main
since_version:
10
function:
False
support_level:
SupportType.COMMON
shape inference:
True
This version of the operator has been available since version 10.
Summary¶
Performs element-wise binary modulus (with Numpy-style broadcasting support). The sign of the remainder is the same as that of the Divisor.
Mod operator can also behave like C fmod() or numpy.fmod. In this case, the sign of the remainder however, will be the same as the Dividend (in contrast to integer mod). To force a behavior like numpy.fmod() an ‘fmod’ Attribute is provided. This attribute is set to 0 by default causing the behavior to be like integer mod. Setting this attribute to 1 causes the remainder to be calculated similar to that of numpy.fmod().
If the input type is floating point, then fmod
attribute must be set to 1.
In case of dividend being zero, the results will be platform dependent.
This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.
Attributes¶
fmod - INT (default is
'0'
):Whether the operator should behave like fmod (default=0 meaning it will do integer mods); Set this to 1 to force fmod treatment
Inputs¶
A (heterogeneous) - T:
Dividend tensor
B (heterogeneous) - T:
Divisor tensor
Outputs¶
C (heterogeneous) - T:
Remainder tensor
Type Constraints¶
T in (
tensor(double)
,tensor(float)
,tensor(float16)
,tensor(int16)
,tensor(int32)
,tensor(int64)
,tensor(int8)
,tensor(uint16)
,tensor(uint32)
,tensor(uint64)
,tensor(uint8)
):Constrain input and output types to high-precision numeric tensors.