Concat#

Concat - 13#

Version

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

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

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=[s for s in in_args], outputs=["output"], axis=i
        )
        output = np.concatenate(values, i)
        expect(
            node,
            inputs=[v for v in 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=[s for s in in_args], outputs=["output"], axis=i
        )
        output = np.concatenate(values, i)
        expect(
            node,
            inputs=[v for v in values],
            outputs=[output],
            name="test_concat_" + test_case + "_axis_negative_" + str(abs(i)),
        )

Concat - 11#

Version

  • name: Concat (GitHub)

  • 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 (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.

Concat - 4#

Version

  • name: Concat (GitHub)

  • 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 (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.

Concat - 1#

Version

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

Concatenate a list of tensors into a single tensor

Attributes

  • axis: 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.