Shape

Outputs the shape of the input tensor into the output tensor.

Inputs

input: tensor of type T1.

Outputs

output: tensor of type T2.

Data Types

T1: bool, int8, int32, float16, float32, bfloat16

T2: int32

Shape Information

input is a tensor with a shape of \([a_0,...,a_n]\), \(n \geq 0\).

output is a shape tensor, where its values are \([a_0,...,a_n]\); when \(n = 0\) output is an empty tensor. Refer to Execution Tensors vs. Shape Tensors for more information on shape tensors.

Examples

Shape
in1 = network.add_input("input1", dtype=trt.float32, shape=(1, 5, 2, 2))
shape = network.add_shape(in1)
network.mark_output(shape.get_output(0))

inputs[in1.name] = np.zeros(shape=(1, 5, 2, 2))

outputs[shape.get_output(0).name] = shape.get_output(0).shape
expected[shape.get_output(0).name] = np.array([1, 5, 2, 2])

C++ API

For more information about the C++ IShapeLayer operator, refer to the C++ IShapeLayer documentation.

Python API

For more information about the Python IShapeLayer operator, refer to the Python IShapeLayer documentation.