concatenate

nvtripy.concatenate(tensors: Sequence[Tensor], dim: int) Tensor[source]

Concatenates the input tensors along the specified dimension.

Parameters:
  • tensors (Sequence[Tensor]) – [dtype=T1] Sequence of tensors to concatenate. They must have identical shapes expect on the concatenation dimension.

  • dim (int) – The dimension along which the tensors are concatenated.

Returns:

[dtype=T1] Concatenated tensor whose shape is the same as the inputs except along dim, whose length is the sum of the lengths of the dim axis of the inputs.

Return type:

Tensor

DATA TYPE CONSTRAINTS:
Example
1a = tp.iota((1, 2), dtype=tp.float32)
2b = tp.iota((2, 2), dtype=tp.float32)
3
4output = tp.concatenate([a, b], dim=0)
Local Variables
>>> a
tensor(
    [[0, 0]], 
    dtype=float32, loc=gpu:0, shape=(1, 2))

>>> b
tensor(
    [[0, 0],
     [1, 1]], 
    dtype=float32, loc=gpu:0, shape=(2, 2))

>>> output
tensor(
    [[0, 0],
     [0, 0],
     [1, 1]], 
    dtype=float32, loc=gpu:0, shape=(3, 2))