Concatenation#
Concatenates input tensors into an output tensor.
Attributes#
axis the axis on which the concatenation is applied. For inputs with rank n
, the default value is \(max(0, n-3)\).
Inputs#
inputs: tensors of type T
. Limited up to 10000 tensors.
Outputs#
output: tensor of type T
.
Data Types#
T: bool
, int8
, int32
, int64
, float16
, float32
, bfloat16
Shape Information#
inputs tensors of rank n
. The tensors’ shapes must match, excluding the axis
dimension.
output tensor of rank n
. The shape is matching the inputs’ shape, excluding the axis
dimension, which is the sum of the axis
dimension of all input tensors.
Volume Limits#
Total number of elements in inputs can be up to \(2^{31}-1\).
DLA Support#
DLA FP16 and DLA INT8 are supported for concatenation across C
dimensions only.
Examples#
Concatenation
in1 = network.add_input("input1", dtype=trt.float32, shape=(1, 1, 2, 5))
in2 = network.add_input("input2", dtype=trt.float32, shape=(1, 2, 2, 5))
in3 = network.add_input("input3", dtype=trt.float32, shape=(1, 1, 2, 5))
layer = network.add_concatenation([in1, in2, in3])
network.mark_output(layer.get_output(0))
inputs[in1.name] = np.array([[[[-3.0, -2.0, -1.0, 10.0, -25.0], [0.0, 1.0, 2.0, -2.0, -1.0]]]])
inputs[in2.name] = np.array(
[[
[[-3.0, -2.0, -1.0, 10.0, -25.0], [0.0, 1.0, 2.0, -2.0, -1.0]],
[[-4.0, -4.0, -4.0, -4.0, -4.0], [-4.0, -4.0, -4.0, -4.0, -4.0]],
]]
)
inputs[in3.name] = np.array([[[[-3.0, -2.0, -1.0, 10.0, -25.0], [0.0, 1.0, 2.0, -2.0, -1.0]]]])
outputs[layer.get_output(0).name] = layer.get_output(0).shape
expected[layer.get_output(0).name] = np.array(
[
[
[[-3.0, -2.0, -1.0, 10.0, -25.0], [0.0, 1.0, 2.0, -2.0, -1.0]],
[[-3.0, -2.0, -1.0, 10.0, -25.0], [0.0, 1.0, 2.0, -2.0, -1.0]],
[[-4.0, -4.0, -4.0, -4.0, -4.0], [-4.0, -4.0, -4.0, -4.0, -4.0]],
[[-3.0, -2.0, -1.0, 10.0, -25.0], [0.0, 1.0, 2.0, -2.0, -1.0]],
]
]
)
C++ API#
For more information about the C++ IConcatenationLayer operator, refer to the C++ IConcatenationLayer documentation.
Python API#
For more information about the Python IConcatenationLayer operator, refer to the Python IConcatenationLayer documentation.