Mul#

  • Domain: ai.onnx

  • Since version: 14

Performs element-wise binary multiplication (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the broadcasting behavior in ONNX.

Inputs

  • A (T): First operand.

  • B (T): Second operand.

Outputs

  • C (T): Result, has same element type as two inputs

Type Constraints

  • T: Constrain input and output types to all 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_mul

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(2, 3), dtype=float32
    [[1., 2., 3.],
     [4., 5., 6.]]
  y: shape=(2, 3), dtype=float32
    [[10., 20., 30.],
     [40., 50., 60.]]

Outputs:
  z: shape=(2, 3), dtype=float32
    [[ 10.,  40.,  90.],
     [160., 250., 360.]]

test_cc_mul_bcast

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(2, 2), dtype=float32
    [[1., 2.],
     [3., 4.]]
  y: shape=(), dtype=float32
    2.

Outputs:
  z: shape=(2, 2), dtype=float32
    [[2., 4.],
     [6., 8.]]

test_cc_mul_bfloat16

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(4,), dtype=bfloat16
    [1, 2, 3, 4]
  y: shape=(4,), dtype=bfloat16
    [0.5, 1.5, 2.5, 3.5]

Outputs:
  z: shape=(4,), dtype=bfloat16
    [0.5, 3, 7.5, 14]

test_cc_mul_double

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(2, 3), dtype=float64
    [[1., 2., 3.],
     [4., 5., 6.]]
  y: shape=(2, 3), dtype=float64
    [[10., 20., 30.],
     [40., 50., 60.]]

Outputs:
  z: shape=(2, 3), dtype=float64
    [[ 10.,  40.,  90.],
     [160., 250., 360.]]

test_cc_mul_empty_shape_scalars

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(), dtype=float32
    2.5
  y: shape=(), dtype=float32
    3.5

Outputs:
  z: shape=(), dtype=float32
    8.75

test_cc_mul_empty_shape_zero_dim

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(0,), dtype=float32
    []
  y: shape=(0,), dtype=float32
    []

Outputs:
  z: shape=(0,), dtype=float32
    []

test_cc_mul_empty_shape_zero_dim_2d

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(0, 3), dtype=float32
    []
  y: shape=(0, 3), dtype=float32
    []

Outputs:
  z: shape=(0, 3), dtype=float32
    []

test_cc_mul_float16

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(2, 3), dtype=float16
    [[1., 2., 3.],
     [4., 5., 6.]]
  y: shape=(2, 3), dtype=float16
    [[10., 20., 30.],
     [40., 50., 60.]]

Outputs:
  z: shape=(2, 3), dtype=float16
    [[ 10.,  40.,  90.],
     [160., 250., 360.]]

test_cc_mul_nan_inf

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(6,), dtype=float32
    [ nan,  inf, -inf,  inf,   1.,   0.]
  y: shape=(6,), dtype=float32
    [  1.,   2.,  -2., -inf,  nan,  inf]

Outputs:
  z: shape=(6,), dtype=float32
    [ nan,  inf,  inf, -inf,  nan,  nan]

test_cc_mul_nan_inf_bcast_inf_scalar

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(4,), dtype=float32
    [ 1., -1.,  2., -2.]
  y: shape=(), dtype=float32
    inf

Outputs:
  z: shape=(4,), dtype=float32
    [ inf, -inf,  inf, -inf]

test_cc_mul_nan_inf_bcast_nan_scalar

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(4,), dtype=float32
    [ 1., -1.,  2., -2.]
  y: shape=(), dtype=float32
    nan

Outputs:
  z: shape=(4,), dtype=float32
    [nan, nan, nan, nan]

test_mul

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=float32
    [[[-2.7012961e+00, -5.5849600e-01,  5.7748574e-01,  6.4741242e-01,
       -7.0523366e-02],
      [-1.1587335e+00, -1.4418545e-01,  8.6498004e-01,  3.7774590e-01,
        3.4641349e-01],
      [ 4.6990660e-04, -1.5549998e+00, -2.0975480e+00,  1.6738971e-01,
        2.1831582e+00],
      [-5.0491732e-01, -3.2653490e-01,  1.5034325e-01, -2.0524660e-01,
        7.2178906e-01]],

     [[-6.2757492e-01, -1.3547317e+00,  5.2883095e-01, -1.1516293e+00,
       -1.2801023e+00],
      [-1.9832895e+00, -1.5061821e-01,  3.7848338e-01, -2.3908144e-01,
        3.6100143e-01],
      [-6.9199687e-01,  4.4155270e-01, -4.1688403e-01, -1.1487823e+00,
       -2.6693258e-01],
      [-1.5721604e-02,  5.1507252e-01, -1.3958987e+00,  6.5033323e-01,
        4.0670735e-01]],

     [[ 4.4503558e-02, -1.2224180e+00,  1.2136942e-01,  7.0311397e-01,
        2.2393616e-01],
      [-1.7902220e+00, -1.6657048e-01,  5.4776672e-02,  1.2022861e+00,
       -1.7855827e+00],
      [ 1.4360319e+00, -9.6935105e-01,  5.9004700e-01, -1.9883904e+00,
       -7.9465955e-01],
      [-1.1217067e+00,  2.5306502e-01, -1.4954242e+00,  1.5923914e+00,
       -2.2547159e-02]]]
  y: shape=(3, 4, 5), dtype=float32
    [[[ 0.5481833 , -0.00939301, -0.45271957, -1.0654595 , -0.32869837],
      [-1.047124  ,  0.67519397, -1.3138133 , -1.0276915 ,  0.20252198],
      [ 0.526426  , -1.6724436 ,  1.8785843 , -0.6158553 ,  1.401629  ],
      [-0.93001837, -0.4439309 , -0.874139  ,  0.50153106, -0.07792282]],

     [[-0.26472604,  1.5117631 ,  0.37530467, -0.536582  ,  0.82635224],
      [ 1.2800639 , -0.14349434, -1.1475542 , -0.45632476,  1.2186408 ],
      [ 0.33088845,  0.29447028,  0.11602481,  1.0672623 ,  0.60493374],
      [ 1.3199029 ,  2.2344162 , -0.30853578,  0.30523637, -1.4056478 ]],

     [[ 0.5731787 , -1.1772175 ,  0.11350691,  2.237379  ,  2.60457   ],
      [ 1.463004  ,  0.20312467,  0.05267026, -0.5475567 ,  0.5086455 ],
      [-0.24070813,  0.7578392 ,  0.16877133,  0.38007334, -2.1396735 ],
      [-0.96594673, -0.32528752,  1.8720994 ,  0.75556403,  0.34925982]]]

Outputs:
  z: shape=(3, 4, 5), dtype=float32
    [[[-1.48080552e+00,  5.24596032e-03, -2.61439085e-01, -6.89791679e-01,
        2.31809150e-02],
      [ 1.21333766e+00, -9.73531455e-02, -1.13642228e+00, -3.88206244e-01,
        7.01563433e-02],
      [ 2.47371063e-04,  2.60064960e+00, -3.94042063e+00, -1.03087835e-01,
        3.05997777e+00],
      [ 4.69582379e-01,  1.44958928e-01, -1.31420910e-01, -1.02937542e-01,
       -5.62438406e-02]],

     [[ 1.66135430e-01, -2.04803348e+00,  1.98472723e-01,  6.17943585e-01,
       -1.05781531e+00],
      [-2.53873730e+00,  2.16128603e-02, -4.34330195e-01,  1.09098777e-01,
        4.39931065e-01],
      [-2.28973776e-01,  1.30024150e-01, -4.83688936e-02, -1.22605193e+00,
       -1.61476523e-01],
      [-2.07509901e-02,  1.15088642e+00,  4.30684686e-01,  1.98505357e-01,
       -5.71687281e-01]],

     [[ 2.55084913e-02,  1.43905175e+00,  1.37762688e-02,  1.57313251e+00,
        5.83257377e-01],
      [-2.61910200e+00, -3.38345766e-02,  2.88510183e-03, -6.58319831e-01,
       -9.08228517e-01],
      [-3.45664561e-01, -7.34612226e-01,  9.95830148e-02, -7.55734205e-01,
        1.70031202e+00],
      [ 1.08350897e+00, -8.23188946e-02, -2.79958272e+00,  1.20315361e+00,
       -7.87481666e-03]]]

test_mul_bcast

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=float32
    [[[ 0.6912245 ,  0.83742934, -0.78804463,  0.6222988 , -0.937902  ],
      [-0.7905085 , -1.8190296 , -0.00926822, -0.08620772, -1.7776535 ],
      [-1.2516913 , -2.1189528 , -0.58901966, -0.08016641, -0.27220273],
      [ 1.530932  , -1.1512946 ,  0.29099432,  0.77937835, -1.1295451 ]],

     [[ 1.4143744 , -0.45160192,  0.1012274 ,  0.30958763,  0.6801167 ],
      [-0.6964468 , -0.02173506,  0.13951953, -1.0011435 ,  0.39252087],
      [-0.74063575,  0.2843027 ,  1.1269056 , -0.16112943,  0.59980184],
      [ 0.01580627, -0.9458842 , -1.501708  , -0.1421285 ,  0.78979415]],

     [[-0.13511205,  0.7731889 , -0.6315761 ,  0.25489986,  0.9365216 ],
      [ 0.6382908 ,  0.41903594,  0.47215635, -0.6030296 ,  1.8355596 ],
      [-0.9491966 , -2.2865195 ,  1.0954932 ,  0.8890692 ,  0.17526741],
      [-0.24671945, -0.6809021 ,  0.22167785,  0.14919838,  0.5840164 ]]]
  y: shape=(5,), dtype=float32
    [-2.4143047 , -0.6895737 , -0.16998304,  1.3226604 , -0.18856247]

Outputs:
  z: shape=(3, 4, 5), dtype=float32
    [[[-1.66882658e+00, -5.77469230e-01,  1.33954227e-01,  8.23089957e-01,
        1.76853105e-01],
      [ 1.90852845e+00,  1.25435495e+00,  1.57544052e-03, -1.14023536e-01,
        3.35198730e-01],
      [ 3.02196431e+00,  1.46117413e+00,  1.00123353e-01, -1.06032938e-01,
        5.13272174e-02],
      [-3.69613624e+00,  7.93902457e-01, -4.94640991e-02,  1.03085291e+00,
        2.12989807e-01]],

     [[-3.41473079e+00,  3.11412811e-01, -1.72069427e-02,  4.09479320e-01,
       -1.28244489e-01],
      [ 1.68143475e+00,  1.49879251e-02, -2.37159543e-02, -1.32417285e+00,
       -7.40147084e-02],
      [ 1.78812039e+00, -1.96047679e-01, -1.91554844e-01, -2.13119522e-01,
       -1.13100111e-01],
      [-3.81611548e-02,  6.52256906e-01,  2.55264908e-01, -1.87987745e-01,
       -1.48925528e-01]],

     [[ 3.26201648e-01, -5.33170700e-01,  1.07357234e-01,  3.37145954e-01,
       -1.76592827e-01],
      [-1.54102850e+00, -2.88956165e-01, -8.02585706e-02, -7.97603428e-01,
       -3.46117646e-01],
      [ 2.29164982e+00,  1.57672369e+00, -1.86215267e-01,  1.17593670e+00,
       -3.30488570e-02],
      [ 5.95655918e-01,  4.69532192e-01, -3.76814753e-02,  1.97338805e-01,
       -1.10123567e-01]]]

test_mul_example

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3,), dtype=float32
    [1., 2., 3.]
  y: shape=(3,), dtype=float32
    [4., 5., 6.]

Outputs:
  z: shape=(3,), dtype=float32
    [ 4., 10., 18.]

test_mul_int16

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=int16
    [[[ 0,  0,  0,  0, -1],
      [ 0,  0,  0, -1,  0],
      [ 2,  0,  0,  1,  1],
      [ 0, -1,  0,  0,  0]],

     [[ 0,  0,  0,  1,  0],
      [ 0, -1,  0, -1,  1],
      [ 0, -1,  0,  0, -1],
      [ 0,  1, -1, -1,  0]],

     [[ 0,  1,  1,  0,  0],
      [-2,  0,  0,  0,  0],
      [ 0,  0,  0,  0, -1],
      [-1,  0,  0,  0,  0]]]
  y: shape=(3, 4, 5), dtype=int16
    [[[ 1,  0, -2,  0,  0],
      [ 1,  1,  1,  0,  0],
      [ 0, -1,  0,  0, -1],
      [-1,  0,  0,  0,  0]],

     [[ 0,  0,  0,  1,  1],
      [ 0,  0, -2,  0,  0],
      [-1,  0,  0,  0,  0],
      [ 0, -1,  0,  0,  1]],

     [[ 0,  0,  1,  0,  0],
      [ 0, -1,  0,  0,  1],
      [ 1,  0, -1,  0,  0],
      [ 0, -1,  0,  0,  0]]]

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

     [[ 0,  0,  0,  1,  0],
      [ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0],
      [ 0, -1,  0,  0,  0]],

     [[ 0,  0,  1,  0,  0],
      [ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0]]]

test_mul_int32

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=int32
    [[[-1,  0,  1,  0, -1],
      [ 0,  0,  0,  0,  0],
      [ 1,  1,  0,  0,  0],
      [ 0,  0,  0,  0,  1]],

     [[ 0,  0,  2,  0,  0],
      [ 0, -1,  0,  0, -1],
      [-1,  0,  0,  1,  2],
      [ 0,  0,  0,  1,  0]],

     [[ 0,  0,  0, -1,  0],
      [-1,  0,  0,  1,  0],
      [ 0,  0,  0,  1,  0],
      [ 0,  0,  0,  0,  0]]]
  y: shape=(3, 4, 5), dtype=int32
    [[[-1,  0,  0, -1,  0],
      [ 0, -1,  0,  0,  0],
      [ 0,  0,  0,  1,  0],
      [ 0, -1,  0,  0, -1]],

     [[-1,  0,  0,  0,  1],
      [-1,  0,  0,  0, -1],
      [ 0,  0,  0,  0,  0],
      [ 0,  0,  0, -1,  0]],

     [[ 0,  1,  0,  0,  0],
      [ 0,  0, -1,  0,  0],
      [ 1,  1, -1,  0,  0],
      [-1,  0,  0,  0,  0]]]

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

     [[ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  1],
      [ 0,  0,  0,  0,  0],
      [ 0,  0,  0, -1,  0]],

     [[ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0]]]

test_mul_int64

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=int64
    [[[ 0,  0,  0,  1,  1],
      [ 0,  0,  0,  0,  0],
      [-1,  0,  0, -1, -2],
      [ 0,  0,  0,  0,  0]],

     [[ 0,  0,  0,  0,  1],
      [ 0,  0,  0,  0,  0],
      [-1,  1,  0,  0,  0],
      [ 0,  0,  0,  0,  0]],

     [[ 0,  2,  0,  1,  0],
      [-1, -1,  0,  1,  0],
      [ 1,  0,  0,  0, -1],
      [ 0,  0,  0, -3,  0]]]
  y: shape=(3, 4, 5), dtype=int64
    [[[ 0, -1,  0, -1,  1],
      [-1,  0,  0,  0,  0],
      [-1,  0,  1,  0,  0],
      [ 1,  0,  0,  0, -1]],

     [[ 0, -2,  0,  0,  0],
      [-1,  1, -1,  0,  0],
      [-1,  0,  0,  0,  0],
      [ 0,  0,  1,  0,  0]],

     [[ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  1,  0],
      [ 1,  0, -1,  0,  0],
      [ 0,  0,  1,  0,  0]]]

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

     [[ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0],
      [ 1,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0]],

     [[ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  1,  0],
      [ 1,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0]]]

test_mul_int8

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=int8
    [[[ 0, -1,  0,  0,  0],
      [ 0,  0,  0,  0,  0],
      [-2,  1,  1, -1,  0],
      [ 1,  0, -2,  0, -1]],

     [[ 0,  0,  1,  0,  0],
      [ 0,  1,  0,  1,  0],
      [ 0, -1,  0,  0,  0],
      [ 0,  0,  0, -2,  0]],

     [[ 0,  0,  0,  0, -1],
      [-1,  0,  0,  0,  1],
      [ 0,  0,  0,  0,  2],
      [ 0,  1, -1,  0,  0]]]
  y: shape=(3, 4, 5), dtype=int8
    [[[ 0,  0,  1, -1,  0],
      [ 1,  0,  0,  0,  0],
      [-1,  2,  1,  0, -1],
      [ 0,  0,  0,  0,  0]],

     [[ 1,  0,  1,  2,  0],
      [ 0, -1,  0,  0,  0],
      [ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0]],

     [[ 0,  0,  0,  0,  0],
      [ 0, -1,  0,  0, -2],
      [ 0,  0,  0,  0,  0],
      [ 0, -1,  0,  0,  0]]]

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

     [[ 0,  0,  1,  0,  0],
      [ 0, -1,  0,  0,  0],
      [ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0,  0]],

     [[ 0,  0,  0,  0,  0],
      [ 0,  0,  0,  0, -2],
      [ 0,  0,  0,  0,  0],
      [ 0, -1,  0,  0,  0]]]

test_mul_uint16

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=uint16
    [[[1, 3, 0, 2, 2],
      [1, 3, 1, 3, 0],
      [1, 2, 3, 0, 0],
      [2, 1, 1, 0, 2]],

     [[3, 0, 2, 2, 3],
      [1, 1, 0, 3, 0],
      [1, 1, 1, 3, 2],
      [3, 0, 2, 3, 2]],

     [[3, 3, 1, 1, 1],
      [2, 0, 0, 2, 3],
      [1, 3, 3, 2, 2],
      [2, 1, 1, 3, 3]]]
  y: shape=(3, 4, 5), dtype=uint16
    [[[11, 17,  4,  7,  7],
      [20, 20, 19, 18,  8],
      [13,  1, 12, 16,  2],
      [17, 22,  7,  0, 18]],

     [[16, 20,  7,  4, 21],
      [16, 17, 15,  7,  4],
      [ 1, 21, 14, 18, 13],
      [13,  7, 16,  1,  8]],

     [[13, 11,  5, 11,  6],
      [14, 15, 15, 19,  2],
      [ 4, 18, 12,  5, 14],
      [ 4,  2,  4, 18, 19]]]

Outputs:
  z: shape=(3, 4, 5), dtype=uint16
    [[[11, 51,  0, 14, 14],
      [20, 60, 19, 54,  0],
      [13,  2, 36,  0,  0],
      [34, 22,  7,  0, 36]],

     [[48,  0, 14,  8, 63],
      [16, 17,  0, 21,  0],
      [ 1, 21, 14, 54, 26],
      [39,  0, 32,  3, 16]],

     [[39, 33,  5, 11,  6],
      [28,  0,  0, 38,  6],
      [ 4, 54, 36, 10, 28],
      [ 8,  2,  4, 54, 57]]]

test_mul_uint32

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=uint32
    [[[0, 3, 1, 2, 0],
      [3, 1, 3, 1, 1],
      [0, 2, 2, 1, 2],
      [3, 2, 0, 3, 0]],

     [[2, 2, 3, 1, 0],
      [0, 2, 2, 1, 0],
      [3, 0, 0, 0, 0],
      [2, 3, 1, 0, 2]],

     [[1, 3, 3, 0, 3],
      [3, 1, 0, 1, 1],
      [1, 2, 0, 0, 2],
      [1, 2, 3, 1, 1]]]
  y: shape=(3, 4, 5), dtype=uint32
    [[[ 3, 23, 15,  4, 16],
      [21,  4,  7,  8, 14],
      [19, 14,  6,  7, 19],
      [18, 19,  0, 10, 12]],

     [[20,  5,  8, 17, 10],
      [ 7, 15,  2,  2, 14],
      [16, 23,  3, 21,  1],
      [10,  4,  8, 12, 16]],

     [[ 3, 20, 21, 21,  4],
      [20,  5, 12, 23, 21],
      [11,  3, 22,  5, 17],
      [ 8,  8, 22,  6,  8]]]

Outputs:
  z: shape=(3, 4, 5), dtype=uint32
    [[[ 0, 69, 15,  8,  0],
      [63,  4, 21,  8, 14],
      [ 0, 28, 12,  7, 38],
      [54, 38,  0, 30,  0]],

     [[40, 10, 24, 17,  0],
      [ 0, 30,  4,  2,  0],
      [48,  0,  0,  0,  0],
      [20, 12,  8,  0, 32]],

     [[ 3, 60, 63,  0, 12],
      [60,  5,  0, 23, 21],
      [11,  6,  0,  0, 34],
      [ 8, 16, 66,  6,  8]]]

test_mul_uint64

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=uint64
    [[[0, 1, 1, 0, 1],
      [3, 2, 2, 0, 2],
      [1, 3, 2, 3, 2],
      [3, 3, 1, 0, 2]],

     [[1, 1, 1, 1, 0],
      [1, 3, 2, 1, 0],
      [2, 3, 1, 2, 3],
      [1, 0, 0, 3, 2]],

     [[1, 1, 1, 3, 3],
      [2, 0, 2, 3, 1],
      [3, 1, 1, 0, 3],
      [1, 3, 1, 0, 3]]]
  y: shape=(3, 4, 5), dtype=uint64
    [[[ 2, 12, 18, 11, 20],
      [18, 23,  7,  5,  1],
      [ 8,  0, 13, 11, 11],
      [13,  6,  8,  0,  3]],

     [[ 7, 20, 16, 21,  4],
      [ 3,  2,  9,  3,  5],
      [ 0, 15, 17,  4,  7],
      [14, 18,  2, 14, 16]],

     [[11, 14, 10,  4,  8],
      [ 5,  5, 22,  3, 17],
      [ 4,  9, 14, 23, 14],
      [ 9, 23, 11, 11, 14]]]

Outputs:
  z: shape=(3, 4, 5), dtype=uint64
    [[[ 0, 12, 18,  0, 20],
      [54, 46, 14,  0,  2],
      [ 8,  0, 26, 33, 22],
      [39, 18,  8,  0,  6]],

     [[ 7, 20, 16, 21,  0],
      [ 3,  6, 18,  3,  0],
      [ 0, 45, 17,  8, 21],
      [14,  0,  0, 42, 32]],

     [[11, 14, 10, 12, 24],
      [10,  0, 44,  9, 17],
      [12,  9, 14,  0, 42],
      [ 9, 69, 11,  0, 42]]]

test_mul_uint8

Node:
  Mul(x, y) -> (z)
Inputs:
  x: shape=(3, 4, 5), dtype=uint8
    [[[2, 0, 1, 0, 3],
      [1, 2, 0, 2, 1],
      [3, 3, 0, 0, 3],
      [3, 1, 2, 1, 0]],

     [[3, 2, 3, 3, 2],
      [3, 2, 2, 3, 3],
      [2, 1, 2, 3, 2],
      [2, 3, 0, 1, 1]],

     [[2, 2, 3, 2, 1],
      [0, 2, 1, 3, 0],
      [3, 2, 3, 1, 0],
      [3, 3, 0, 1, 3]]]
  y: shape=(3, 4, 5), dtype=uint8
    [[[15, 13, 23, 13, 16],
      [14, 23,  4,  1,  8],
      [ 0,  3,  8, 19, 14],
      [22,  9, 21, 20, 13]],

     [[ 4, 13, 23,  3, 18],
      [ 7,  0, 11, 14,  8],
      [ 9,  1, 12,  6, 22],
      [16,  7, 10, 11, 10]],

     [[ 9, 14, 12,  1, 17],
      [ 9, 21, 21,  1, 14],
      [23, 16,  5, 14, 14],
      [ 3,  6, 14, 12, 14]]]

Outputs:
  z: shape=(3, 4, 5), dtype=uint8
    [[[30,  0, 23,  0, 48],
      [14, 46,  0,  2,  8],
      [ 0,  9,  0,  0, 42],
      [66,  9, 42, 20,  0]],

     [[12, 26, 69,  9, 36],
      [21,  0, 22, 42, 24],
      [18,  1, 24, 18, 44],
      [32, 21,  0, 11, 10]],

     [[18, 28, 36,  2, 17],
      [ 0, 42, 21,  3,  0],
      [69, 32, 15, 14,  0],
      [ 9, 18,  0, 12, 42]]]

Differences with previous version (13)#

SchemaDiff: Mul (domain 'ai.onnx')

  • old version: 13

  • new version: 14

  • breaking: no

Type constraints:

  • changed ‘T’: added types: [‘tensor(int16)’, ‘tensor(int8)’, ‘tensor(uint16)’, ‘tensor(uint8)’]

Version History#