Mod#

  • Domain: ai.onnx

  • Since version: 13

Performs an element-wise binary modulo operation.

Inputs

  • A (T): Dividend tensor

  • B (T): Divisor tensor

Outputs

  • C (T): Remainder tensor

Type Constraints

  • T: Constrain input and output types to high-precision numeric tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8).

Examples#

test_cc_mod_bfloat16_fmod

Node:
  Mod(x, y) -> (z)
  Attributes:
    fmod = 1
Inputs:
  x: shape=(3,), dtype=bfloat16
    [4.5, -4.5, 7]
  y: shape=(3,), dtype=bfloat16
    [3, 3, 2.5]

Outputs:
  z: shape=(3,), dtype=bfloat16
    [1.5, -1.5, 2]

test_mod_broadcast

Node:
  Mod(x, y) -> (z)
Inputs:
  x: shape=(3, 2, 5), dtype=int32
    [[[ 0,  1,  2,  3,  4],
      [ 5,  6,  7,  8,  9]],

     [[10, 11, 12, 13, 14],
      [15, 16, 17, 18, 19]],

     [[20, 21, 22, 23, 24],
      [25, 26, 27, 28, 29]]]
  y: shape=(1,), dtype=int32
    [7]

Outputs:
  z: shape=(3, 2, 5), dtype=int32
    [[[0, 1, 2, 3, 4],
      [5, 6, 0, 1, 2]],

     [[3, 4, 5, 6, 0],
      [1, 2, 3, 4, 5]],

     [[6, 0, 1, 2, 3],
      [4, 5, 6, 0, 1]]]

test_mod_int64_fmod

Node:
  Mod(x, y) -> (z)
  Attributes:
    fmod = 1
Inputs:
  x: shape=(6,), dtype=int64
    [-4,  7,  5,  4, -7,  8]
  y: shape=(6,), dtype=int64
    [ 2, -3,  8, -2,  3,  5]

Outputs:
  z: shape=(6,), dtype=int64
    [ 0,  1,  5,  0, -1,  3]

test_mod_mixed_sign_bfloat16

Node:
  Mod(x, y) -> (z)
  Attributes:
    fmod = 1
Inputs:
  x: shape=(6,), dtype=bfloat16
    [-4, 7, 5, 4, -7, 8]
  y: shape=(6,), dtype=bfloat16
    [2, -3, 8, -2, 3, 5]

Outputs:
  z: shape=(6,), dtype=bfloat16
    [-0, 1, 5, 0, -1, 3]

test_mod_mixed_sign_float16

Node:
  Mod(x, y) -> (z)
  Attributes:
    fmod = 1
Inputs:
  x: shape=(6,), dtype=float16
    [-4.3,  7.2,  5. ,  4.3, -7.2,  8. ]
  y: shape=(6,), dtype=float16
    [ 2.1, -3.4,  8. , -2.1,  3.4,  5. ]

Outputs:
  z: shape=(6,), dtype=float16
    [-0.10156,  0.3984 ,  5.     ,  0.10156, -0.3984 ,  3.     ]

test_mod_mixed_sign_float32

Node:
  Mod(x, y) -> (z)
  Attributes:
    fmod = 1
Inputs:
  x: shape=(6,), dtype=float32
    [-4.3,  7.2,  5. ,  4.3, -7.2,  8. ]
  y: shape=(6,), dtype=float32
    [ 2.1, -3.4,  8. , -2.1,  3.4,  5. ]

Outputs:
  z: shape=(6,), dtype=float32
    [-0.10000038,  0.39999962,  5.        ,  0.10000038, -0.39999962,  3.        ]

test_mod_mixed_sign_float64

Node:
  Mod(x, y) -> (z)
  Attributes:
    fmod = 1
Inputs:
  x: shape=(6,), dtype=float64
    [-4.3,  7.2,  5. ,  4.3, -7.2,  8. ]
  y: shape=(6,), dtype=float64
    [ 2.1, -3.4,  8. , -2.1,  3.4,  5. ]

Outputs:
  z: shape=(6,), dtype=float64
    [-0.1,  0.4,  5. ,  0.1, -0.4,  3. ]

test_mod_mixed_sign_int16

Node:
  Mod(x, y) -> (z)
Inputs:
  x: shape=(6,), dtype=int16
    [-4,  7,  5,  4, -7,  8]
  y: shape=(6,), dtype=int16
    [ 2, -3,  8, -2,  3,  5]

Outputs:
  z: shape=(6,), dtype=int16
    [ 0, -2,  5,  0,  2,  3]

test_mod_mixed_sign_int32

Node:
  Mod(x, y) -> (z)
Inputs:
  x: shape=(6,), dtype=int32
    [-4,  7,  5,  4, -7,  8]
  y: shape=(6,), dtype=int32
    [ 2, -3,  8, -2,  3,  5]

Outputs:
  z: shape=(6,), dtype=int32
    [ 0, -2,  5,  0,  2,  3]

test_mod_mixed_sign_int64

Node:
  Mod(x, y) -> (z)
Inputs:
  x: shape=(6,), dtype=int64
    [-4,  7,  5,  4, -7,  8]
  y: shape=(6,), dtype=int64
    [ 2, -3,  8, -2,  3,  5]

Outputs:
  z: shape=(6,), dtype=int64
    [ 0, -2,  5,  0,  2,  3]

test_mod_mixed_sign_int8

Node:
  Mod(x, y) -> (z)
Inputs:
  x: shape=(6,), dtype=int8
    [-4,  7,  5,  4, -7,  8]
  y: shape=(6,), dtype=int8
    [ 2, -3,  8, -2,  3,  5]

Outputs:
  z: shape=(6,), dtype=int8
    [ 0, -2,  5,  0,  2,  3]

test_mod_uint16

Node:
  Mod(x, y) -> (z)
Inputs:
  x: shape=(3,), dtype=uint16
    [4, 7, 5]
  y: shape=(3,), dtype=uint16
    [2, 3, 8]

Outputs:
  z: shape=(3,), dtype=uint16
    [0, 1, 5]

test_mod_uint32

Node:
  Mod(x, y) -> (z)
Inputs:
  x: shape=(3,), dtype=uint32
    [4, 7, 5]
  y: shape=(3,), dtype=uint32
    [2, 3, 8]

Outputs:
  z: shape=(3,), dtype=uint32
    [0, 1, 5]

test_mod_uint64

Node:
  Mod(x, y) -> (z)
Inputs:
  x: shape=(3,), dtype=uint64
    [4, 7, 5]
  y: shape=(3,), dtype=uint64
    [2, 3, 8]

Outputs:
  z: shape=(3,), dtype=uint64
    [0, 1, 5]

test_mod_uint8

Node:
  Mod(x, y) -> (z)
Inputs:
  x: shape=(3,), dtype=uint8
    [4, 7, 5]
  y: shape=(3,), dtype=uint8
    [2, 3, 8]

Outputs:
  z: shape=(3,), dtype=uint8
    [0, 1, 5]

Differences with previous version (10)#

SchemaDiff: Mod (domain 'ai.onnx')

  • old version: 10

  • new version: 13

  • breaking: no

Type constraints:

  • changed ‘T’: added types: [‘tensor(bfloat16)’]

Documentation:

  • line similarity: 0.00 (+1/-1 lines)

--- Mod v10
+++ Mod v13
@@ -1 +1 @@
-Performs element-wise binary modulus.
+Performs an element-wise binary modulo operation.

Version History#