asc2.concat

asc2.concat(*inputs: LocalTensor) LocalTensor

Concatenate tensors along the first dimension.

All input tensors must have the same shape except for the first dimension, and must have the same data type.

The supported data types are: int8, int16, int32, int64, float16, bfloat16, float32.

Parameters:

inputs – Two or more tensors to concatenate

Returns:

A new tensor that is the concatenation of all input tensors along the first dimension

Return type:

LocalTensor

Raises:
  • TypeError – If any input is not a LocalTensor

  • RuntimeError – If no inputs are provided, shapes are incompatible, dtypes don’t match, or tensor dtype size does not fit an integer number of bytes

Examples

Concatenate two tensors along the first dimension:

input_a = asc2.copy_in(x_gm, [0, 0], [64, 32])
input_b = asc2.copy_in(y_gm, [64, 0], [64, 32])
result = asc2.concat(input_a, input_b)  # shape: [128, 32]

Concatenate multiple tensors:

tensors = [asc2.copy_in(x_gm, [0, 0], [32, 16]), asc2.copy_in(x_gm, [32, 0], [16, 16]),
           asc2.copy_in(x_gm, [64, 0], [8, 16]), asc2.maximum(input_a, input_b)]
result = asc2.concat(*tensors)  # shape: [120, 16]