Layer Base Classes¶
ITensor¶
-
tensorrt.
TensorLocation
¶ The physical location of the data.
Members:
DEVICE : Data is stored on the device.
HOST : Data is stored on the device.
-
class
tensorrt.
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. - 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. If the tensor is a network input or output, then the tensor type cannot betensorrt.int8
. - broadcast_across_batch –
bool
Whether to enable broadcast of tensor across the batch. When a tensor is broadcast across a batch, it has the same value for every member in the batch. Memory is only allocated once for the single member. This method is only valid for network input tensors, since the flags of layer output tensors are inferred based on layer inputs and parameters. If this state is modified for a tensor in the network, the states of all dependent tensors will be recomputed. - 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.
-
get_dynamic_range
(self: tensorrt.tensorrt.ITensor) → float¶ Get dynamic range for the tensor.
Returns: absolute maxima of the dynamic range.
-
set_dynamic_range
(self: tensorrt.tensorrt.ITensor, min: float, max: float) → bool¶ Set dynamic range for the tensor.
Parameters: - min – Minima of the dynamic range.
- max – Maxima of the dyanmic range.
Returns: true if succeed in setting range. Otherwise false.
- name –
ILayer¶
-
tensorrt.
LayerType
¶ Type of Layer
Members:
LRN : LRN layer
MATRIX_MULTIPLY : Matrix multiply layer
CONCATENATION : Concatenation layer
RNN_V2 : RNNv2 layer
UNARY : Unary layer
PLUGIN_V2 : PluginV2 layer
POOLING : Pooling layer
CONSTANT : Constant layer
PADDING : Padding layer
DECONVOLUTION : Deconvolution layer
FULLY_CONNECTED : Fully connected layer
SCALE : Scale layer
ELEMENTWISE : Elementwise layer
TOPK : TopK layer
ACTIVATION : Activation layer
SHUFFLE : Shuffle layer
GATHER : Gather layer
RAGGED_SOFTMAX : Ragged softmax layer
SOFTMAX : Softmax layer
IDENTITY : Identity layer
RNN : RNN layer
REDUCE : Reduce layer
PLUGIN : Plugin layer
CONVOLUTION : Convolution layer
-
class
tensorrt.
ILayer
¶ Base class for all layer classes in an
INetworkDefinition
.Variables: -
get_input
(self: tensorrt.tensorrt.ILayer, index: int) → tensorrt.tensorrt.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.tensorrt.ILayer, index: int) → tensorrt.tensorrt.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.tensorrt.ILayer, index: int) → tensorrt.tensorrt.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.tensorrt.ILayer, index: int) → bool¶ 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.tensorrt.ILayer, index: int) → None¶ Reset output type of this layer.
Parameters: index – The index of the output.
-
reset_precision
(self: tensorrt.tensorrt.ILayer) → None¶ Reset the computation precision of the layer.
-
set_output_type
(self: tensorrt.tensorrt.ILayer, index: int, dtype: tensorrt.tensorrt.DataType) → None¶ Constraint layer to generate output data with given type.
Parameters: - index – The index of the output tensor to set the type.
- dtype – DataType of the output.
-