Layer Base Classes¶
ITensor¶
- class tensorrt_rtx.ITensor¶
A tensor in an
INetworkDefinition
.- Variables:
name –
str
The tensor name. For a network input, the name is assigned by the application. For tensors which are layer outputs, a default name is assigned consisting of the layer name followed by the index of the output in brackets. Each network input and output tensor must have a unique name.shape –
Dims
The shape of a tensor. For a network input the shape is assigned by the application. For a network output it is computed based on the layer parameters and the inputs to the layer. If a tensor size or a parameter is modified in the network, the shape of all dependent tensors will be recomputed. This call is only legal for network input tensors, since the shape of layer output tensors are inferred based on layer inputs and parameters.dtype –
DataType
The data type of a tensor. The type is unchanged if the type is invalid for the given tensor.broadcast_across_batch –
bool
[DEPRECATED] Deprecated in TensorRT 10.0. Always false since the implicit batch dimensions support has been removed.location –
TensorLocation
The storage location of a tensor.is_network_input –
bool
Whether the tensor is a network input.is_network_output –
bool
Whether the tensor is a network output.dynamic_range –
Tuple[float, float]
[DEPRECATED] Deprecated in TensorRT 10.1. Superseded by explicit quantization. A tuple containing the [minimum, maximum] of the dynamic range, orNone
if the range was not set.is_shape –
bool
Whether the tensor is a shape tensor.allowed_formats –
int32
The allowed set of TensorFormat candidates. This should be an integer consisting of one or moreTensorFormat
s, combined via bitwise OR after bit shifting. For example,1 << int(TensorFormat.CHW4) | 1 << int(TensorFormat.CHW32)
.
- get_dimension_name(self: tensorrt_rtx.tensorrt_rtx.ITensor, index: int) str ¶
Get the name of an input dimension.
- Parameters:
index – index of the dimension.
- Returns:
name of the dimension, or null if dimension is unnamed.
- set_dimension_name(self: tensorrt_rtx.tensorrt_rtx.ITensor, index: int, name: str) None ¶
Name a dimension of an input tensor.
Associate a runtime dimension of an input tensor with a symbolic name. Dimensions with the same non-empty name must be equal at runtime. Knowing this equality for runtime dimensions may help the TensorRT optimizer. Both runtime and build-time dimensions can be named. If the function is called again, with the same index, it will overwrite the previous name. If None is passed as name, it will clear the name of the dimension.
For example, setDimensionName(0, “n”) associates the symbolic name “n” with the leading dimension.
- Parameters:
index – index of the dimension.
name – name of the dimension.
ILayer¶
- class tensorrt_rtx.ILayer¶
Base class for all layer classes in an
INetworkDefinition
.- Variables:
name –
str
The name of the layer.type –
LayerType
The type of the layer.num_inputs –
int
The number of inputs of the layer.num_outputs –
int
The number of outputs of the layer.precision –
DataType
The computation precision.precision_is_set –
bool
Whether the precision is set or not.
- Ival metadata:
str
The per-layer metadata.
- get_input(self: tensorrt_rtx.tensorrt_rtx.ILayer, index: int) tensorrt_rtx.tensorrt_rtx.ITensor ¶
Get the layer input corresponding to the given index.
- Parameters:
index – The index of the input tensor.
- Returns:
The input tensor, or
None
if the index is out of range.
- get_output(self: tensorrt_rtx.tensorrt_rtx.ILayer, index: int) tensorrt_rtx.tensorrt_rtx.ITensor ¶
Get the layer output corresponding to the given index.
- Parameters:
index – The index of the output tensor.
- Returns:
The output tensor, or
None
if the index is out of range.
- get_output_type(self: tensorrt_rtx.tensorrt_rtx.ILayer, index: int) tensorrt_rtx.tensorrt_rtx.DataType ¶
Get the output type of the layer.
- Parameters:
index – The index of the output tensor.
- Returns:
The output precision. Default : DataType.FLOAT.
- output_type_is_set(self: tensorrt_rtx.tensorrt_rtx.ILayer, index: int) bool ¶
[DEPRECATED] Deprecated in TensorRT 10.12. Superseded by strong typing. Whether the output type has been set for this layer.
- Parameters:
index – The index of the output.
- Returns:
Whether the output type has been explicitly set.
- reset_output_type(self: tensorrt_rtx.tensorrt_rtx.ILayer, index: int) None ¶
[DEPRECATED] Deprecated in TensorRT 10.12. Superseded by strong typing. Reset output type of this layer.
- Parameters:
index – The index of the output.
- reset_precision(self: tensorrt_rtx.tensorrt_rtx.ILayer) None ¶
[DEPRECATED] Deprecated in TensorRT 10.12. Superseded by strong typing. Reset the computation precision of the layer.
- set_input(self: tensorrt_rtx.tensorrt_rtx.ILayer, index: int, tensor: tensorrt_rtx.tensorrt_rtx.ITensor) None ¶
Set the layer input corresponding to the given index.
- Parameters:
index – The index of the input tensor.
tensor – The input tensor.
- set_output_type(self: tensorrt_rtx.tensorrt_rtx.ILayer, index: int, dtype: tensorrt_rtx.tensorrt_rtx.DataType) None ¶
[DEPRECATED] Deprecated in TensorRT 10.12. Superseded by strong typing. Constraint layer to generate output data with given type. Note that this method cannot be used to set the data type of the second output tensor of the topK layer. The data type of the second output tensor of the topK layer is always
int32
.- Parameters:
index – The index of the output tensor to set the type.
dtype – DataType of the output.