(l-onnx-doc-Concat)= # Concat (l-onnx-op-concat-13)= ## Concat - 13 ### Version - **name**: [Concat (GitHub)](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Concat) - **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 Concatenate a list of tensors into a single tensor. All input tensors must have the same shape, except for the dimension size of the axis to concatenate on. ### Attributes * **axis - INT** (required) : Which axis to concat on. A negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(inputs).. ### Inputs Between 1 and 2147483647 inputs. - **inputs** (variadic, heterogeneous) - **T**: List of tensors for concatenation ### Outputs - **concat_result** (heterogeneous) - **T**: Concatenated tensor ### Type Constraints * **T** in ( `tensor(bfloat16)`, `tensor(bool)`, `tensor(complex128)`, `tensor(complex64)`, `tensor(double)`, `tensor(float)`, `tensor(float16)`, `tensor(int16)`, `tensor(int32)`, `tensor(int64)`, `tensor(int8)`, `tensor(string)`, `tensor(uint16)`, `tensor(uint32)`, `tensor(uint64)`, `tensor(uint8)` ): Constrain output types to any tensor type. ### Examples #### default ```python import numpy as np import onnx test_cases: dict[str, Sequence[Any]] = { "1d": ([1, 2], [3, 4]), "2d": ([[1, 2], [3, 4]], [[5, 6], [7, 8]]), "3d": ( [[[1, 2], [3, 4]], [[5, 6], [7, 8]]], [[[9, 10], [11, 12]], [[13, 14], [15, 16]]], ), } for test_case, values_ in test_cases.items(): values = [np.asarray(v, dtype=np.float32) for v in values_] for i in range(len(values[0].shape)): in_args = ["value" + str(k) for k in range(len(values))] node = onnx.helper.make_node( "Concat", inputs=list(in_args), outputs=["output"], axis=i ) output = np.concatenate(values, i) expect( node, inputs=list(values), outputs=[output], name="test_concat_" + test_case + "_axis_" + str(i), ) for i in range(-len(values[0].shape), 0): in_args = ["value" + str(k) for k in range(len(values))] node = onnx.helper.make_node( "Concat", inputs=list(in_args), outputs=["output"], axis=i ) output = np.concatenate(values, i) expect( node, inputs=list(values), outputs=[output], name="test_concat_" + test_case + "_axis_negative_" + str(abs(i)), ) ``` ```{toctree} text_diff_Concat_11_13 ``` (l-onnx-op-concat-11)= ## Concat - 11 ### Version - **name**: [Concat (GitHub)](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Concat) - **domain**: `main` - **since_version**: `11` - **function**: `False` - **support_level**: `SupportType.COMMON` - **shape inference**: `True` This version of the operator has been available **since version 11**. ### Summary Concatenate a list of tensors into a single tensor. All input tensors must have the same shape, except for the dimension size of the axis to concatenate on. ### Attributes * **axis - INT** (required) : Which axis to concat on. A negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(inputs).. ### Inputs Between 1 and 2147483647 inputs. - **inputs** (variadic, heterogeneous) - **T**: List of tensors for concatenation ### Outputs - **concat_result** (heterogeneous) - **T**: Concatenated tensor ### Type Constraints * **T** in ( `tensor(bool)`, `tensor(complex128)`, `tensor(complex64)`, `tensor(double)`, `tensor(float)`, `tensor(float16)`, `tensor(int16)`, `tensor(int32)`, `tensor(int64)`, `tensor(int8)`, `tensor(string)`, `tensor(uint16)`, `tensor(uint32)`, `tensor(uint64)`, `tensor(uint8)` ): Constrain output types to any tensor type. ```{toctree} text_diff_Concat_4_13 text_diff_Concat_4_11 ``` (l-onnx-op-concat-4)= ## Concat - 4 ### Version - **name**: [Concat (GitHub)](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Concat) - **domain**: `main` - **since_version**: `4` - **function**: `False` - **support_level**: `SupportType.COMMON` - **shape inference**: `True` This version of the operator has been available **since version 4**. ### Summary Concatenate a list of tensors into a single tensor ### Attributes * **axis - INT** (required) : Which axis to concat on ### Inputs Between 1 and 2147483647 inputs. - **inputs** (variadic, heterogeneous) - **T**: List of tensors for concatenation ### Outputs - **concat_result** (heterogeneous) - **T**: Concatenated tensor ### Type Constraints * **T** in ( `tensor(bool)`, `tensor(complex128)`, `tensor(complex64)`, `tensor(double)`, `tensor(float)`, `tensor(float16)`, `tensor(int16)`, `tensor(int32)`, `tensor(int64)`, `tensor(int8)`, `tensor(string)`, `tensor(uint16)`, `tensor(uint32)`, `tensor(uint64)`, `tensor(uint8)` ): Constrain output types to any tensor type. ```{toctree} text_diff_Concat_1_13 text_diff_Concat_1_11 text_diff_Concat_1_4 ``` (l-onnx-op-concat-1)= ## Concat - 1 ### Version - **name**: [Concat (GitHub)](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Concat) - **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 Concatenate a list of tensors into a single tensor ### Attributes * **axis - INT** : Which axis to concat on. Default value is 1. ### Inputs Between 1 and 2147483647 inputs. - **inputs** (variadic, heterogeneous) - **T**: List of tensors for concatenation ### Outputs - **concat_result** (heterogeneous) - **T**: Concatenated tensor ### Type Constraints * **T** in ( `tensor(double)`, `tensor(float)`, `tensor(float16)` ): Constrain output types to float tensors.