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_cc_add

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

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]]

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#