Add#

  • Domain: ai.onnx

  • Since version: 14

Performs element-wise binary addition (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_add

Node:
  Add(x, y) -> (sum)
Inputs:
  x: shape=(3, 4, 5), dtype=float32
    [[[-0.846573  ,  1.2833743 ,  0.7443729 , -0.53892165, -0.18734488],
      [ 0.12178429, -2.0982637 ,  1.5225194 ,  0.8434675 ,  0.33549327],
      [ 0.09154005,  0.84206796, -1.6517702 , -0.6042637 ,  1.0845611 ],
      [ 1.5201056 ,  0.99814653, -0.17626205,  1.6406455 ,  0.7513234 ]],

     [[ 1.7203773 , -1.0786597 ,  0.17007604,  0.51496613,  0.2197246 ],
      [-1.1963571 ,  0.40040365, -1.2112149 , -0.33787218, -1.3460412 ],
      [ 0.7294753 ,  0.6825587 , -1.2590255 , -2.3378267 , -0.7833349 ],
      [ 1.8637013 , -0.9699887 , -1.1392695 , -0.08200161, -1.0864431 ]],

     [[-2.0017872 , -1.6769867 ,  0.01457232,  0.58369064,  1.4740808 ],
      [ 0.33742025,  1.0194283 , -0.9550304 ,  1.0498446 , -0.16838181],
      [ 0.04257414,  1.3051497 , -1.2076538 , -0.4271947 , -1.4134941 ],
      [ 0.7686854 ,  1.2206558 , -1.1196595 , -1.1292622 , -0.41522065]]]
  y: shape=(3, 4, 5), dtype=float32
    [[[-1.233148  ,  0.13186626,  0.7939877 ,  0.4511548 ,  0.17302549],
      [-1.5203902 ,  0.49947104, -0.45518056, -0.561509  , -0.2619732 ],
      [ 0.7643679 , -0.5008771 , -1.6715151 , -1.0876864 ,  0.5858355 ],
      [ 0.23310411,  0.8712918 ,  0.08240927, -0.22854084,  0.3831807 ]],

     [[ 2.166861  ,  0.8242299 ,  0.07636173,  0.1569699 , -0.9098289 ],
      [-1.2892655 ,  1.7136036 ,  0.452536  , -0.3871883 ,  0.8681424 ],
      [ 0.64394414, -0.11681466, -0.55781925,  1.5857856 ,  0.96086985],
      [ 0.36460796, -1.7471066 , -0.6675202 , -0.9307984 , -0.81704015]],

     [[ 0.04730104, -0.42357075,  0.6734053 ,  0.58307636,  1.2070061 ],
      [-0.21970329,  0.09768768, -0.29589003, -0.2054249 ,  0.8043798 ],
      [ 0.6403441 ,  0.47908017, -2.3431432 , -0.43361774, -1.4350805 ],
      [ 2.3141932 , -0.77084607,  0.03072728, -0.6819856 ,  0.3865685 ]]]

Outputs:
  sum: shape=(3, 4, 5), dtype=float32
    [[[-2.079721  ,  1.4152405 ,  1.5383606 , -0.08776686, -0.01431939],
      [-1.3986058 , -1.5987927 ,  1.0673388 ,  0.28195846,  0.07352006],
      [ 0.8559079 ,  0.34119087, -3.3232853 , -1.6919501 ,  1.6703966 ],
      [ 1.7532097 ,  1.8694384 , -0.09385278,  1.4121046 ,  1.1345041 ]],

     [[ 3.8872385 , -0.25442976,  0.24643777,  0.67193604, -0.6901043 ],
      [-2.4856226 ,  2.1140072 , -0.7586789 , -0.72506046, -0.47789878],
      [ 1.3734195 ,  0.56574404, -1.8168447 , -0.7520411 ,  0.17753494],
      [ 2.2283094 , -2.7170954 , -1.8067896 , -1.0128    , -1.9034832 ]],

     [[-1.9544861 , -2.1005573 ,  0.6879776 ,  1.166767  ,  2.681087  ],
      [ 0.11771697,  1.117116  , -1.2509204 ,  0.8444197 ,  0.635998  ],
      [ 0.68291825,  1.7842299 , -3.550797  , -0.8608124 , -2.8485746 ],
      [ 3.0828786 ,  0.44980973, -1.0889323 , -1.8112478 , -0.02865216]]]

test_add_bcast

Node:
  Add(x, y) -> (sum)
Inputs:
  x: shape=(3, 4, 5), dtype=float32
    [[[-1.0009542 ,  1.3335403 ,  0.51886207, -0.87937015, -0.34444883],
      [ 0.7261377 ,  0.44689482, -0.11980146,  1.3952885 ,  1.7246119 ],
      [ 1.1329428 , -0.75994855,  1.0185796 , -1.1640126 , -1.4462589 ],
      [ 1.9671117 , -0.78563446, -0.6370028 , -0.6990264 , -0.05147265]],

     [[-0.93405545, -1.5452816 , -0.27895346, -0.28968734,  1.3620633 ],
      [ 0.25097892,  0.15541512, -0.5576033 ,  0.56766975,  0.5894251 ],
      [-2.0840185 , -2.129933  , -0.3347914 ,  2.2643888 , -0.5795392 ],
      [ 1.4404445 , -1.6125345 , -0.38877857,  0.26226655, -0.65531564]],

     [[ 0.41839996, -0.17184599, -1.1314857 , -0.20180649,  1.4405026 ],
      [-0.71997935, -0.674459  , -0.47517473, -0.01454322,  0.70281273],
      [ 0.09478609, -0.51084805, -0.6076167 ,  0.76374954,  1.212502  ],
      [-0.83932626,  0.27163088, -0.34415314, -0.098693  , -0.49040416]]]
  y: shape=(5,), dtype=float32
    [ 0.08745956, -1.0263144 , -0.35410684, -0.36685738, -2.0796497 ]

Outputs:
  sum: shape=(3, 4, 5), dtype=float32
    [[[-0.9134946 ,  0.30722594,  0.16475523, -1.2462275 , -2.4240985 ],
      [ 0.81359726, -0.57941955, -0.4739083 ,  1.028431  , -0.3550378 ],
      [ 1.2204024 , -1.786263  ,  0.66447276, -1.53087   , -3.5259085 ],
      [ 2.0545712 , -1.8119488 , -0.99110967, -1.0658838 , -2.1311224 ]],

     [[-0.8465959 , -2.5715961 , -0.63306034, -0.6565447 , -0.7175864 ],
      [ 0.33843848, -0.87089926, -0.91171014,  0.20081237, -1.4902246 ],
      [-1.9965589 , -3.1562476 , -0.6888982 ,  1.8975314 , -2.6591887 ],
      [ 1.527904  , -2.6388488 , -0.7428854 , -0.10459083, -2.7349653 ]],

     [[ 0.5058595 , -1.1981604 , -1.4855926 , -0.56866384, -0.63914704],
      [-0.6325198 , -1.7007734 , -0.82928157, -0.38140061, -1.376837  ],
      [ 0.18224566, -1.5371624 , -0.96172357,  0.39689216, -0.8671477 ],
      [-0.7518667 , -0.7546835 , -0.69825995, -0.46555036, -2.5700538 ]]]

test_add_int16

Node:
  Add(x, y) -> (sum)
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:
  sum: shape=(3, 4, 5), dtype=int16
    [[[ 1,  0, -2,  0, -1],
      [ 1,  1,  1, -1,  0],
      [ 2, -1,  0,  1,  0],
      [-1, -1,  0,  0,  0]],

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

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

test_add_int32

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

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

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

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

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

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

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

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

test_add_int64

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

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

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

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

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

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

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

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

test_add_int8

Node:
  Add(x, y) -> (sum)
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:
  sum: shape=(3, 4, 5), dtype=int8
    [[[ 0, -1,  1, -1,  0],
      [ 1,  0,  0,  0,  0],
      [-3,  3,  2, -1, -1],
      [ 1,  0, -2,  0, -1]],

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

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

test_add_uint16

Node:
  Add(x, y) -> (sum)
Inputs:
  x: shape=(3, 4, 5), dtype=uint16
    [[[21, 11, 16, 14,  6],
      [21, 15,  5, 19,  8],
      [21,  6,  3,  8, 20],
      [22,  9,  1,  4,  2]],

     [[11,  0, 22, 22,  3],
      [ 1, 13, 16,  7, 16],
      [ 9, 21, 13,  3,  2],
      [23,  0,  6, 11, 18]],

     [[19, 11,  9,  1, 17],
      [22, 16,  4, 10,  3],
      [ 5, 15, 23, 22, 10],
      [22,  1, 21, 11,  7]]]
  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:
  sum: shape=(3, 4, 5), dtype=uint16
    [[[32, 28, 20, 21, 13],
      [41, 35, 24, 37, 16],
      [34,  7, 15, 24, 22],
      [39, 31,  8,  4, 20]],

     [[27, 20, 29, 26, 24],
      [17, 30, 31, 14, 20],
      [10, 42, 27, 21, 15],
      [36,  7, 22, 12, 26]],

     [[32, 22, 14, 12, 23],
      [36, 31, 19, 29,  5],
      [ 9, 33, 35, 27, 24],
      [26,  3, 25, 29, 26]]]

test_add_uint32

Node:
  Add(x, y) -> (sum)
Inputs:
  x: shape=(3, 4, 5), dtype=uint32
    [[[ 0, 19,  9,  6, 12],
      [ 7,  1, 23, 17, 17],
      [20, 14, 10,  9, 14],
      [ 3, 14, 12, 19,  0]],

     [[14, 10,  7, 21,  4],
      [ 0,  6,  6,  5, 12],
      [ 3,  8, 16,  0,  0],
      [ 6,  3, 13,  4, 18]],

     [[ 5, 19,  7, 20, 15],
      [19, 21, 12, 17,  1],
      [ 5, 22, 16,  8, 14],
      [ 5, 14, 15,  5,  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:
  sum: shape=(3, 4, 5), dtype=uint32
    [[[ 3, 42, 24, 10, 28],
      [28,  5, 30, 25, 31],
      [39, 28, 16, 16, 33],
      [21, 33, 12, 29, 12]],

     [[34, 15, 15, 38, 14],
      [ 7, 21,  8,  7, 26],
      [19, 31, 19, 21,  1],
      [16,  7, 21, 16, 34]],

     [[ 8, 39, 28, 41, 19],
      [39, 26, 24, 40, 22],
      [16, 25, 38, 13, 31],
      [13, 22, 37, 11,  9]]]

test_add_uint64

Node:
  Add(x, y) -> (sum)
Inputs:
  x: shape=(3, 4, 5), dtype=uint64
    [[[16,  1,  1, 16, 17],
      [15,  6,  2, 16,  2],
      [ 5, 23, 18, 23, 22],
      [23, 19,  1, 12, 18]],

     [[ 1, 21, 21, 13,  8],
      [ 5,  7,  2,  5, 16],
      [ 2, 11,  1, 22,  3],
      [17,  4, 12, 19, 10]],

     [[ 9, 21,  1, 11, 19],
      [ 2, 16, 10, 15,  5],
      [ 3,  9, 21, 12,  3],
      [17, 23,  5,  0, 19]]]
  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:
  sum: shape=(3, 4, 5), dtype=uint64
    [[[18, 13, 19, 27, 37],
      [33, 29,  9, 21,  3],
      [13, 23, 31, 34, 33],
      [36, 25,  9, 12, 21]],

     [[ 8, 41, 37, 34, 12],
      [ 8,  9, 11,  8, 21],
      [ 2, 26, 18, 26, 10],
      [31, 22, 14, 33, 26]],

     [[20, 35, 11, 15, 27],
      [ 7, 21, 32, 18, 22],
      [ 7, 18, 35, 35, 17],
      [26, 46, 16, 11, 33]]]

test_add_uint8

Node:
  Add(x, y) -> (sum)
Inputs:
  x: shape=(3, 4, 5), dtype=uint8
    [[[22, 20,  5,  8,  7],
      [21, 14,  4, 22, 17],
      [ 7, 19,  0,  4, 23],
      [15, 17, 14,  1,  0]],

     [[ 7,  2, 19, 19, 10],
      [ 7,  2,  2, 11,  7],
      [22,  1,  6, 11, 18],
      [ 6,  7, 16,  1, 17]],

     [[14,  2, 19, 18, 17],
      [16, 14, 21, 23,  0],
      [11, 18, 15, 13, 20],
      [11,  3,  0, 17, 11]]]
  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:
  sum: shape=(3, 4, 5), dtype=uint8
    [[[37, 33, 28, 21, 23],
      [35, 37,  8, 23, 25],
      [ 7, 22,  8, 23, 37],
      [37, 26, 35, 21, 13]],

     [[11, 15, 42, 22, 28],
      [14,  2, 13, 25, 15],
      [31,  2, 18, 17, 40],
      [22, 14, 26, 12, 27]],

     [[23, 16, 31, 19, 34],
      [25, 35, 42, 24, 14],
      [34, 34, 20, 27, 34],
      [14,  9, 14, 29, 25]]]

test_cc_add

Node:
  Add(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
    [[11., 22., 33.],
     [44., 55., 66.]]

test_cc_add_bcast

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

Outputs:
  z: shape=(2, 2), dtype=float32
    [[1.5, 2.5],
     [3.5, 4.5]]

test_cc_add_bfloat16

Node:
  Add(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
    [1.5, 3.5, 5.5, 7.5]

test_cc_add_double

Node:
  Add(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
    [[11., 22., 33.],
     [44., 55., 66.]]

test_cc_add_empty_shape_scalars

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

Outputs:
  z: shape=(), dtype=float32
    6.

test_cc_add_empty_shape_zero_dim

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

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

test_cc_add_empty_shape_zero_dim_2d

Node:
  Add(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_add_float16

Node:
  Add(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
    [[11., 22., 33.],
     [44., 55., 66.]]

test_cc_add_nan_inf

Node:
  Add(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,  nan,  nan,  inf]

test_cc_add_nan_inf_bcast_inf_scalar

Node:
  Add(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_add_nan_inf_bcast_nan_scalar

Node:
  Add(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]

Differences with previous version (13)#

SchemaDiff: Add (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#