Concat#

  • Domain: ai.onnx

  • Since version: 13

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.

Inputs

  • inputs (T): List of tensors for concatenation

Outputs

  • concat_result (T): Concatenated tensor

Type Constraints

  • T: Constrain output types to any tensor type. Allowed types: 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).

Examples#

test_cc_concat_1d_axis_0

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = 0
Inputs:
  value0: shape=(2,), dtype=float32
    [1., 2.]
  value1: shape=(2,), dtype=float32
    [3., 4.]

Outputs:
  output: shape=(4,), dtype=float32
    [1., 2., 3., 4.]

test_cc_concat_1d_axis_negative_1

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = -1
Inputs:
  value0: shape=(2,), dtype=float32
    [1., 2.]
  value1: shape=(2,), dtype=float32
    [3., 4.]

Outputs:
  output: shape=(4,), dtype=float32
    [1., 2., 3., 4.]

test_cc_concat_2d_axis_0

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = 0
Inputs:
  value0: shape=(2, 2), dtype=float32
    [[1., 2.],
     [3., 4.]]
  value1: shape=(2, 2), dtype=float32
    [[5., 6.],
     [7., 8.]]

Outputs:
  output: shape=(4, 2), dtype=float32
    [[1., 2.],
     [3., 4.],
     [5., 6.],
     [7., 8.]]

test_cc_concat_2d_axis_1

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = 1
Inputs:
  value0: shape=(2, 2), dtype=float32
    [[1., 2.],
     [3., 4.]]
  value1: shape=(2, 2), dtype=float32
    [[5., 6.],
     [7., 8.]]

Outputs:
  output: shape=(2, 4), dtype=float32
    [[1., 2., 5., 6.],
     [3., 4., 7., 8.]]

test_cc_concat_2d_axis_negative_1

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = -1
Inputs:
  value0: shape=(2, 2), dtype=float32
    [[1., 2.],
     [3., 4.]]
  value1: shape=(2, 2), dtype=float32
    [[5., 6.],
     [7., 8.]]

Outputs:
  output: shape=(2, 4), dtype=float32
    [[1., 2., 5., 6.],
     [3., 4., 7., 8.]]

test_cc_concat_2d_axis_negative_2

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = -2
Inputs:
  value0: shape=(2, 2), dtype=float32
    [[1., 2.],
     [3., 4.]]
  value1: shape=(2, 2), dtype=float32
    [[5., 6.],
     [7., 8.]]

Outputs:
  output: shape=(4, 2), dtype=float32
    [[1., 2.],
     [3., 4.],
     [5., 6.],
     [7., 8.]]

test_cc_concat_3d_axis_0

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = 0
Inputs:
  value0: shape=(2, 2, 2), dtype=float32
    [[[1., 2.],
      [3., 4.]],

     [[5., 6.],
      [7., 8.]]]
  value1: shape=(2, 2, 2), dtype=float32
    [[[ 9., 10.],
      [11., 12.]],

     [[13., 14.],
      [15., 16.]]]

Outputs:
  output: shape=(4, 2, 2), dtype=float32
    [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]],

     [[ 9., 10.],
      [11., 12.]],

     [[13., 14.],
      [15., 16.]]]

test_cc_concat_3d_axis_1

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = 1
Inputs:
  value0: shape=(2, 2, 2), dtype=float32
    [[[1., 2.],
      [3., 4.]],

     [[5., 6.],
      [7., 8.]]]
  value1: shape=(2, 2, 2), dtype=float32
    [[[ 9., 10.],
      [11., 12.]],

     [[13., 14.],
      [15., 16.]]]

Outputs:
  output: shape=(2, 4, 2), dtype=float32
    [[[ 1.,  2.],
      [ 3.,  4.],
      [ 9., 10.],
      [11., 12.]],

     [[ 5.,  6.],
      [ 7.,  8.],
      [13., 14.],
      [15., 16.]]]

test_cc_concat_3d_axis_2

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = 2
Inputs:
  value0: shape=(2, 2, 2), dtype=float32
    [[[1., 2.],
      [3., 4.]],

     [[5., 6.],
      [7., 8.]]]
  value1: shape=(2, 2, 2), dtype=float32
    [[[ 9., 10.],
      [11., 12.]],

     [[13., 14.],
      [15., 16.]]]

Outputs:
  output: shape=(2, 2, 4), dtype=float32
    [[[ 1.,  2.,  9., 10.],
      [ 3.,  4., 11., 12.]],

     [[ 5.,  6., 13., 14.],
      [ 7.,  8., 15., 16.]]]

test_cc_concat_3d_axis_negative_1

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = -1
Inputs:
  value0: shape=(2, 2, 2), dtype=float32
    [[[1., 2.],
      [3., 4.]],

     [[5., 6.],
      [7., 8.]]]
  value1: shape=(2, 2, 2), dtype=float32
    [[[ 9., 10.],
      [11., 12.]],

     [[13., 14.],
      [15., 16.]]]

Outputs:
  output: shape=(2, 2, 4), dtype=float32
    [[[ 1.,  2.,  9., 10.],
      [ 3.,  4., 11., 12.]],

     [[ 5.,  6., 13., 14.],
      [ 7.,  8., 15., 16.]]]

test_cc_concat_3d_axis_negative_2

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = -2
Inputs:
  value0: shape=(2, 2, 2), dtype=float32
    [[[1., 2.],
      [3., 4.]],

     [[5., 6.],
      [7., 8.]]]
  value1: shape=(2, 2, 2), dtype=float32
    [[[ 9., 10.],
      [11., 12.]],

     [[13., 14.],
      [15., 16.]]]

Outputs:
  output: shape=(2, 4, 2), dtype=float32
    [[[ 1.,  2.],
      [ 3.,  4.],
      [ 9., 10.],
      [11., 12.]],

     [[ 5.,  6.],
      [ 7.,  8.],
      [13., 14.],
      [15., 16.]]]

test_cc_concat_3d_axis_negative_3

Node:
  Concat(value0, value1) -> (output)
  Attributes:
    axis = -3
Inputs:
  value0: shape=(2, 2, 2), dtype=float32
    [[[1., 2.],
      [3., 4.]],

     [[5., 6.],
      [7., 8.]]]
  value1: shape=(2, 2, 2), dtype=float32
    [[[ 9., 10.],
      [11., 12.]],

     [[13., 14.],
      [15., 16.]]]

Outputs:
  output: shape=(4, 2, 2), dtype=float32
    [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]],

     [[ 9., 10.],
      [11., 12.]],

     [[13., 14.],
      [15., 16.]]]

Differences with previous version (11)#

SchemaDiff: Concat (domain 'ai.onnx')

  • old version: 11

  • new version: 13

  • breaking: no

Type constraints:

  • changed ‘T’: added types: [‘tensor(bfloat16)’]

Version History#