# Sum#

## Sum - 13#

Version

• name: Sum (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

Element-wise sum of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

• data_0 (variadic, heterogeneous) - T: List of tensors for sum.

Outputs

• sum (heterogeneous) - T: Output tensor.

Type Constraints

• T in ( tensor(bfloat16), tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.

Examples

default

```data_0 = np.array([3, 0, 2]).astype(np.float32)
data_1 = np.array([1, 3, 4]).astype(np.float32)
data_2 = np.array([2, 6, 6]).astype(np.float32)
result = np.array([6, 9, 12]).astype(np.float32)
node = onnx.helper.make_node(
"Sum",
inputs=["data_0", "data_1", "data_2"],
outputs=["result"],
)
expect(
node,
inputs=[data_0, data_1, data_2],
outputs=[result],
name="test_sum_example",
)

node = onnx.helper.make_node(
"Sum",
inputs=["data_0"],
outputs=["result"],
)
expect(node, inputs=[data_0], outputs=[data_0], name="test_sum_one_input")

node = onnx.helper.make_node(
"Sum",
inputs=["data_0", "data_1"],
outputs=["result"],
)
expect(
node, inputs=[data_0, data_1], outputs=[result], name="test_sum_two_inputs"
)
```

Differences

 `0` `0` `Element-wise sum of each of the input tensors (with Numpy-style broadcasting support).` `Element-wise sum of each of the input tensors (with Numpy-style broadcasting support).` `1` `1` `All inputs and outputs must have the same data type.` `All inputs and outputs must have the same data type.` `2` `2` `This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX _.` `This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX _.` `3` `3` `4` `4` `**Inputs**` `**Inputs**` `5` `5` `6` `6` `Between 1 and 2147483647 inputs.` `Between 1 and 2147483647 inputs.` `7` `7` `8` `8` `* **data_0** (variadic, heterogeneous) - **T**:` `* **data_0** (variadic, heterogeneous) - **T**:` `9` `9` ` List of tensors for sum.` ` List of tensors for sum.` `10` `10` `11` `11` `**Outputs**` `**Outputs**` `12` `12` `13` `13` `* **sum** (heterogeneous) - **T**:` `* **sum** (heterogeneous) - **T**:` `14` `14` ` Output tensor.` ` Output tensor.` `15` `15` `16` `16` `**Type Constraints**` `**Type Constraints**` `17` `17` `18` `18` `* **T** in (` `* **T** in (` `19` ` tensor(bfloat16),` `19` `20` ` tensor(double),` ` tensor(double),` `20` `21` ` tensor(float),` ` tensor(float),` `21` `22` ` tensor(float16)` ` tensor(float16)` `22` `23` ` ):` ` ):` `23` `24` ` Constrain input and output types to float tensors.` ` Constrain input and output types to float tensors.`

## Sum - 8#

Version

• name: Sum (GitHub)

• domain: main

• since_version: 8

• function: False

• support_level: SupportType.COMMON

• shape inference: True

This version of the operator has been available since version 8.

Summary

Element-wise sum of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.

Inputs

Between 1 and 2147483647 inputs.

• data_0 (variadic, heterogeneous) - T: List of tensors for sum.

Outputs

• sum (heterogeneous) - T: Output tensor.

Type Constraints

• T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.

Differences

 `0` `Element-wise sum of each of the input tensors (with Numpy-style broadcasting support).` `1` `All inputs and outputs must have the same data type.` `0` `2` `Element-wise sum of each of the input tensors. All inputs and outputs must` `This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX _.` `1` `have the same shape and data type.` `2` `3` `3` `4` `**Inputs**` `**Inputs**` `4` `5` `5` `6` `Between 1 and 2147483647 inputs.` `Between 1 and 2147483647 inputs.` `6` `7` `7` `8` `* **data_0** (variadic, heterogeneous) - **T**:` `* **data_0** (variadic, heterogeneous) - **T**:` `8` `9` ` List of tensors for Sum.` ` List of tensors for sum.` `9` `10` `10` `11` `**Outputs**` `**Outputs**` `11` `12` `12` `13` `* **sum** (heterogeneous) - **T**:` `* **sum** (heterogeneous) - **T**:` `13` `14` ` Output tensor. Same dimension as inputs.` ` Output tensor.` `14` `15` `15` `16` `**Type Constraints**` `**Type Constraints**` `16` `17` `17` `18` `* **T** in (` `* **T** in (` `18` `19` ` tensor(double),` ` tensor(double),` `19` `20` ` tensor(float),` ` tensor(float),` `20` `21` ` tensor(float16)` ` tensor(float16)` `21` `22` ` ):` ` ):` `22` `23` ` Constrain input and output types to float tensors.` ` Constrain input and output types to float tensors.`

## Sum - 6#

Version

• name: Sum (GitHub)

• domain: main

• since_version: 6

• function: False

• support_level: SupportType.COMMON

• shape inference: True

This version of the operator has been available since version 6.

Summary

Element-wise sum of each of the input tensors. All inputs and outputs must have the same shape and data type.

Inputs

Between 1 and 2147483647 inputs.

• data_0 (variadic, heterogeneous) - T: List of tensors for Sum.

Outputs

• sum (heterogeneous) - T: Output tensor. Same dimension as inputs.

Type Constraints

• T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.

Differences

 `0` `0` `Element-wise sum of each of the input tensors. All inputs and outputs must` `Element-wise sum of each of the input tensors. All inputs and outputs must` `1` `1` `have the same shape and data type.` `have the same shape and data type.` `2` `2` `3` `**Attributes**` `4` `5` `* **consumed_inputs**:` `6` ` legacy optimization attribute.` `7` `8` `3` `**Inputs**` `**Inputs**` `9` `4` `10` `5` `Between 1 and 2147483647 inputs.` `Between 1 and 2147483647 inputs.` `11` `6` `12` `7` `* **data_0** (variadic, heterogeneous) - **T**:` `* **data_0** (variadic, heterogeneous) - **T**:` `13` `8` ` List of tensors for Sum.` ` List of tensors for Sum.` `14` `9` `15` `10` `**Outputs**` `**Outputs**` `16` `11` `17` `12` `* **sum** (heterogeneous) - **T**:` `* **sum** (heterogeneous) - **T**:` `18` `13` ` Output tensor. Same dimension as inputs.` ` Output tensor. Same dimension as inputs.` `19` `14` `20` `15` `**Type Constraints**` `**Type Constraints**` `21` `16` `22` `17` `* **T** in (` `* **T** in (` `23` `18` ` tensor(double),` ` tensor(double),` `24` `19` ` tensor(float),` ` tensor(float),` `25` `20` ` tensor(float16)` ` tensor(float16)` `26` `21` ` ):` ` ):` `27` `22` ` Constrain input and output types to float tensors.` ` Constrain input and output types to float tensors.`

## Sum - 1#

Version

• name: Sum (GitHub)

• domain: main

• since_version: 1

• function: False

• support_level: SupportType.COMMON

• shape inference: False

This version of the operator has been available since version 1.

Summary

Element-wise sum of each of the input tensors. All inputs and outputs must have the same shape and data type.

Attributes

• consumed_inputs: legacy optimization attribute.

Inputs

Between 1 and 2147483647 inputs.

• data_0 (variadic, heterogeneous) - T: List of tensors for Sum.

Outputs

• sum (heterogeneous) - T: Output tensor. Same dimension as inputs.

Type Constraints

• T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.