Identity¶
Outputs the given input tensor to the output tensor. When a tensor precision is explicitly specified, the input is transformed from one precision to another.
Other than conversions between the same type (float32
-> float32
for example), the only valid conversions are:
(float32
| float16
| int32
| bool
) -> (float32
| float16
| int32
| bool
)
(float32
| float16
) -> uint8
uint8
-> (float32
| float16
)
Inputs¶
input: tensor of type T1
.
Outputs¶
output: tensor of type T2
.
Data Types¶
T1: bool
, int8
, uint8
, int32
, float16
, float32
T2: bool
, int8
, uint8
, int32
, float16
, float32
Shape Information¶
input and output are tensors with a shape of \([a_0,...,a_n]\)
Examples¶
Identity
in1 = network.add_input("input1", dtype=trt.float32, shape=(1, 1, 3, 3))
layer = network.add_identity(in1)
network.mark_output(layer.get_output(0))
inputs[in1.name] = np.array(
[
[
[
[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0],
[7.0, 8.0, 9.0],
]
]
]
)
outputs[layer.get_output(0).name] = layer.get_output(0).shape
expected[layer.get_output(0).name] = inputs[in1.name]
Identity with a Different Precision
in1 = network.add_input("input1", dtype=trt.float32, shape=(1, 1, 3, 3))
layer = network.add_identity(in1)
layer.set_output_type(0, dtype=trt.int32)
layer2 = network.add_identity(layer.get_output(0))
network.mark_output(layer2.get_output(0))
inputs[in1.name] = np.array(
[
[
[
[1.1, 2.4, 3.7],
[4.2, 5.5, 6.8],
[7.3, 8.6, 9.9],
]
]
]
)
outputs[layer2.get_output(0).name] = layer2.get_output(0).shape
expected[layer2.get_output(0).name] = np.array(
[
[
[
[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0],
[7.0, 8.0, 9.0],
]
]
]
)
C++ API¶
For more information about the C++ IIdentityLayer operator, refer to the C++ IIdentityLayer documentation.
Python API¶
For more information about the Python IIdentityLayer operator, refer to the Python IIdentityLayer documentation.