ConcatOperation

Applicable Products

Hardware Model

Supported

Atlas 350 accelerator cards

√

Atlas A3 inference products/Atlas A3 training products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas training products

√

Atlas inference products

√

Atlas 200I/500 A2 inference products

√

Description

Combines two input tensors into an output tensor at a specified dimension.

Figure 1 Implementation principle of the Concat operator

Operator Context

Figure 2 ConcatOperation

Definition

1
2
3
4
struct ConcatParam {
    int concatDim = 0;
    uint8_t rsv[12] = {0};
};

Parameters

Member

Type

Default Value

Description

concatDim

int

0

Dimension index for concat.

Assume that the dimension index for concatenation is k and the number of dimensions of x is dimNum:

  • When concatDim is a negative number, the access starts from the highest dimension. k = dimNum + concatDim. For example, if concatDim is -1, the concatenation dimension k is dimNum - 1.
  • Otherwise, k = concatDim.

rsv[12]

uint8_t

{0}

Reserved

Input

Parameter

Dimension

Data Type

Format

Description

x

[x_dim_0, x_dim_1, ... , x_dim_n]

float16/bf16

ND

Tensor to be concatenated.

y

[y_dim_0, y_dim_1, ... , y_dim_n]

float16/bf16

ND

Tensor to be concatenated. The dimensions except y_dim_k are the same as those of x.

Output

Parameter

Dimension

Data Type

Format

Description

output

[dim_0, dim_1, ..., dim_n]

float16/bf16

ND

Concatenated tensor.

Constraints

  • Restrictions on the parameters:
    • dimNum: number of dimensions of the concatenated tensor.
    • -dimNum ≤ concatDim ≤ dimNum - 1.
  • Input constraints
    • The inputs x and y have the same dimensions.
    • The dimension size of the inputs x and y must be the same except the concatDim dimension.

API Calling Example

  • Input
    x shape = [3, 2, 3]:
    [[[1.0, 1.0, 1.0],
      [1.0, 1.0, 1.0]],
     [[1.0, 1.0, 1.0],
      [1.0, 1.0, 1.0]],
     [[1.0, 1.0, 1.0],
      [1.0, 1.0, 1.0]]]
    y shape = [3, 1, 3]:
    [[[2.0, 2.0, 2.0]],
     [[2.0, 2.0, 2.0]],
     [[2.0, 2.0, 2.0]]]
    param.concatDim = 1 (or -2)
  • Output
    output shape = [3, 3, 3]
    [[[1.0, 1.0, 1.0],
      [1.0, 1.0, 1.0],
      [2.0, 2.0, 2.0]],
     [[1.0, 1.0, 1.0],
      [1.0, 1.0, 1.0],
      [2.0, 2.0, 2.0]],
     [[1.0, 1.0, 1.0],
      [1.0, 1.0, 1.0],
      [2.0, 2.0, 2.0]]]