TensorRT 8.6.0
|
A network definition for input to the builder. More...
#include <NvInfer.h>
Public Member Functions | |
virtual | ~INetworkDefinition () noexcept=default |
ITensor * | addInput (char const *name, DataType type, Dims dimensions) noexcept |
Add an input tensor to the network. More... | |
void | markOutput (ITensor &tensor) noexcept |
Mark a tensor as a network output. More... | |
TRT_DEPRECATED IConvolutionLayer * | addConvolution (ITensor &input, int32_t nbOutputMaps, DimsHW kernelSize, Weights kernelWeights, Weights biasWeights) noexcept |
Add a convolution layer to the network. More... | |
TRT_DEPRECATED IFullyConnectedLayer * | addFullyConnected (ITensor &input, int32_t nbOutputs, Weights kernelWeights, Weights biasWeights) noexcept |
Add a fully connected layer to the network. More... | |
IActivationLayer * | addActivation (ITensor &input, ActivationType type) noexcept |
Add an activation layer to the network. More... | |
TRT_DEPRECATED IPoolingLayer * | addPooling (ITensor &input, PoolingType type, DimsHW windowSize) noexcept |
Add a pooling layer to the network. More... | |
ILRNLayer * | addLRN (ITensor &input, int32_t window, float alpha, float beta, float k) noexcept |
Add a LRN layer to the network. More... | |
IScaleLayer * | addScale (ITensor &input, ScaleMode mode, Weights shift, Weights scale, Weights power) noexcept |
Add a Scale layer to the network. More... | |
ISoftMaxLayer * | addSoftMax (ITensor &input) noexcept |
Add a SoftMax layer to the network. More... | |
IConcatenationLayer * | addConcatenation (ITensor *const *inputs, int32_t nbInputs) noexcept |
Add a concatenation layer to the network. More... | |
TRT_DEPRECATED IDeconvolutionLayer * | addDeconvolution (ITensor &input, int32_t nbOutputMaps, DimsHW kernelSize, Weights kernelWeights, Weights biasWeights) noexcept |
Add a deconvolution layer to the network. More... | |
IElementWiseLayer * | addElementWise (ITensor &input1, ITensor &input2, ElementWiseOperation op) noexcept |
Add an elementwise layer to the network. More... | |
IUnaryLayer * | addUnary (ITensor &input, UnaryOperation operation) noexcept |
Add a unary layer to the network. More... | |
TRT_DEPRECATED IPaddingLayer * | addPadding (ITensor &input, DimsHW prePadding, DimsHW postPadding) noexcept |
Add a padding layer to the network. More... | |
IShuffleLayer * | addShuffle (ITensor &input) noexcept |
Add a shuffle layer to the network. More... | |
IOneHotLayer * | addOneHot (ITensor &indices, ITensor &values, ITensor &depth, int32_t axis) noexcept |
Add a OneHot layer to the network. More... | |
int32_t | getNbLayers () const noexcept |
Get the number of layers in the network. More... | |
ILayer * | getLayer (int32_t index) const noexcept |
Get the layer specified by the given index. More... | |
int32_t | getNbInputs () const noexcept |
Get the number of inputs in the network. More... | |
ITensor * | getInput (int32_t index) const noexcept |
Get the input tensor specified by the given index. More... | |
int32_t | getNbOutputs () const noexcept |
Get the number of outputs in the network. More... | |
ITensor * | getOutput (int32_t index) const noexcept |
Get the output tensor specified by the given index. More... | |
TRT_DEPRECATED void | destroy () noexcept |
Destroy this INetworkDefinition object. More... | |
IReduceLayer * | addReduce (ITensor &input, ReduceOperation operation, uint32_t reduceAxes, bool keepDimensions) noexcept |
Add a reduce layer to the network. More... | |
ITopKLayer * | addTopK (ITensor &input, TopKOperation op, int32_t k, uint32_t reduceAxes) noexcept |
Add a TopK layer to the network. More... | |
IGatherLayer * | addGather (ITensor &data, ITensor &indices, int32_t axis) noexcept |
Add gather with mode GatherMode::kDEFAULT and specified axis and nbElementWiseDims=0. More... | |
IGatherLayer * | addGatherV2 (ITensor &data, ITensor &indices, GatherMode mode) noexcept |
Add gather with specified mode, axis=0 and nbElementWiseDims=0. More... | |
IRaggedSoftMaxLayer * | addRaggedSoftMax (ITensor &input, ITensor &bounds) noexcept |
Add a RaggedSoftMax layer to the network. More... | |
IMatrixMultiplyLayer * | addMatrixMultiply (ITensor &input0, MatrixOperation op0, ITensor &input1, MatrixOperation op1) noexcept |
Add a MatrixMultiply layer to the network. More... | |
INonZeroLayer * | addNonZero (ITensor &input) noexcept |
Add a nonzero layer to the network. More... | |
IConstantLayer * | addConstant (Dims dimensions, Weights weights) noexcept |
Add a constant layer to the network. More... | |
TRT_DEPRECATED IRNNv2Layer * | addRNNv2 (ITensor &input, int32_t layerCount, int32_t hiddenSize, int32_t maxSeqLen, RNNOperation op) noexcept |
Add an layerCount deep RNN layer to the network with hiddenSize internal states that can take a batch with fixed or variable sequence lengths. More... | |
IIdentityLayer * | addIdentity (ITensor &input) noexcept |
Add an identity layer. More... | |
ICastLayer * | addCast (ITensor &input, DataType toType) noexcept |
Add a cast layer. More... | |
void | removeTensor (ITensor &tensor) noexcept |
remove a tensor from the network definition. More... | |
void | unmarkOutput (ITensor &tensor) noexcept |
unmark a tensor as a network output. More... | |
IPluginV2Layer * | addPluginV2 (ITensor *const *inputs, int32_t nbInputs, IPluginV2 &plugin) noexcept |
Add a plugin layer to the network using the IPluginV2 interface. More... | |
ISliceLayer * | addSlice (ITensor &input, Dims start, Dims size, Dims stride) noexcept |
Add a slice layer to the network. More... | |
void | setName (char const *name) noexcept |
Sets the name of the network. More... | |
char const * | getName () const noexcept |
Returns the name associated with the network. More... | |
IShapeLayer * | addShape (ITensor &input) noexcept |
Add a shape layer to the network. More... | |
bool | hasImplicitBatchDimension () const noexcept |
Query whether the network was created with an implicit batch dimension. More... | |
bool | markOutputForShapes (ITensor &tensor) noexcept |
Enable tensor's value to be computed by IExecutionContext::getShapeBinding. More... | |
bool | unmarkOutputForShapes (ITensor &tensor) noexcept |
Undo markOutputForShapes. More... | |
IParametricReLULayer * | addParametricReLU (ITensor &input, ITensor &slope) noexcept |
Add a parametric ReLU layer to the network. More... | |
IConvolutionLayer * | addConvolutionNd (ITensor &input, int32_t nbOutputMaps, Dims kernelSize, Weights kernelWeights, Weights biasWeights) noexcept |
Add a multi-dimension convolution layer to the network. More... | |
IPoolingLayer * | addPoolingNd (ITensor &input, PoolingType type, Dims windowSize) noexcept |
Add a multi-dimension pooling layer to the network. More... | |
IDeconvolutionLayer * | addDeconvolutionNd (ITensor &input, int32_t nbOutputMaps, Dims kernelSize, Weights kernelWeights, Weights biasWeights) noexcept |
Add a multi-dimension deconvolution layer to the network. More... | |
IScaleLayer * | addScaleNd (ITensor &input, ScaleMode mode, Weights shift, Weights scale, Weights power, int32_t channelAxis) noexcept |
Add a multi-dimension scale layer to the network. More... | |
IResizeLayer * | addResize (ITensor &input) noexcept |
Add a resize layer to the network. More... | |
TRT_DEPRECATED bool | hasExplicitPrecision () const noexcept |
True if network is an explicit precision network. More... | |
ILoop * | addLoop () noexcept |
Add a loop to the network. More... | |
ISelectLayer * | addSelect (ITensor &condition, ITensor &thenInput, ITensor &elseInput) noexcept |
Add a select layer to the network. More... | |
IAssertionLayer * | addAssertion (ITensor &condition, char const *message) noexcept |
Add an assertion layer to the network. More... | |
IFillLayer * | addFill (Dims dimensions, FillOperation op) noexcept |
Add a fill layer to the network. More... | |
TRT_DEPRECATED IPaddingLayer * | addPaddingNd (ITensor &input, Dims prePadding, Dims postPadding) noexcept |
Add a padding layer to the network. Only 2D padding is currently supported. More... | |
bool | setWeightsName (Weights weights, char const *name) noexcept |
Associate a name with all current uses of the given weights. More... | |
void | setErrorRecorder (IErrorRecorder *recorder) noexcept |
Set the ErrorRecorder for this interface. More... | |
IErrorRecorder * | getErrorRecorder () const noexcept |
get the ErrorRecorder assigned to this interface. More... | |
IDequantizeLayer * | addDequantize (ITensor &input, ITensor &scale) noexcept |
Add a dequantization layer to the network. More... | |
IScatterLayer * | addScatter (ITensor &data, ITensor &indices, ITensor &updates, ScatterMode mode) noexcept |
Add a Scatter layer to the network with specified mode and axis=0. More... | |
IQuantizeLayer * | addQuantize (ITensor &input, ITensor &scale) noexcept |
Add a quantization layer to the network. More... | |
IIfConditional * | addIfConditional () noexcept |
Add an If-conditional layer to the network. More... | |
IEinsumLayer * | addEinsum (ITensor *const *inputs, int32_t nbInputs, char const *equation) noexcept |
Add an Einsum layer to the network. More... | |
IGridSampleLayer * | addGridSample (ITensor &input, ITensor &grid) noexcept |
Add a GridSample layer to the network. More... | |
INMSLayer * | addNMS (ITensor &boxes, ITensor &scores, ITensor &maxOutputBoxesPerClass) noexcept |
Add a non-maximum suppression layer to the network. More... | |
IReverseSequenceLayer * | addReverseSequence (ITensor &input, ITensor &sequenceLens) noexcept |
Add a ReverseSequence layer to the network. More... | |
INormalizationLayer * | addNormalization (ITensor &input, ITensor &scale, ITensor &bias, uint32_t axesMask) noexcept |
Add a normalization layer to the network. More... | |
virtual IBuilder & | getBuilder () const noexcept |
Return the builder from which this INetworkDefinition was created. More... | |
Protected Attributes | |
apiv::VNetworkDefinition * | mImpl |
Additional Inherited Members | |
![]() | |
INoCopy ()=default | |
virtual | ~INoCopy ()=default |
INoCopy (INoCopy const &other)=delete | |
INoCopy & | operator= (INoCopy const &other)=delete |
INoCopy (INoCopy &&other)=delete | |
INoCopy & | operator= (INoCopy &&other)=delete |
A network definition for input to the builder.
A network definition defines the structure of the network, and combined with a IBuilderConfig, is built into an engine using an IBuilder. An INetworkDefinition can either have an implicit batch dimensions, specified at runtime, or all dimensions explicit, full dims mode, in the network definition. The former mode, i.e. the implicit batch size mode, has been deprecated. The function hasImplicitBatchDimension() can be used to query the mode of the network.
A network with implicit batch dimensions returns the dimensions of a layer without the implicit dimension, and instead the batch is specified at execute/enqueue time. If the network has all dimensions specified, then the first dimension follows elementwise broadcast rules: if it is 1 for some inputs and is some value N for all other inputs, then the first dimension of each output is N, and the inputs with 1 for the first dimension are broadcast. Having divergent batch sizes across inputs to a layer is not supported.
|
virtualdefaultnoexcept |
|
inlinenoexcept |
Add an activation layer to the network.
input | The input tensor to the layer. |
type | The type of activation function to apply. |
Note that the setAlpha() and setBeta() methods must be used on the output for activations that require these parameters.
|
inlinenoexcept |
Add an assertion layer to the network.
condition | The input tensor to the layer. |
message | A message to print if the assertion fails. |
The input tensor must be a boolean shape tensor.
|
inlinenoexcept |
Add a cast layer.
input | The input tensor to the layer. |
toType | The DataType of the output tensor |
|
inlinenoexcept |
Add a concatenation layer to the network.
inputs | The input tensors to the layer. |
nbInputs | The number of input tensors. |
|
inlinenoexcept |
Add a constant layer to the network.
dimensions | The dimensions of the constant. |
weights | The constant value, represented as weights. |
If weights.type is DataType::kINT32, the output is a tensor of 32-bit indices. Otherwise the output is a tensor of real values and the output type will be follow TensorRT's normal precision rules.
If tensors in the network have an implicit batch dimension, the constant is broadcast over that dimension.
If a wildcard dimension is used, the volume of the runtime dimensions must equal the number of weights specified.
|
inlinenoexcept |
Add a convolution layer to the network.
input | The input tensor to the convolution. |
nbOutputMaps | The number of output feature maps for the convolution. |
kernelSize | The HW-dimensions of the convolution kernel. |
kernelWeights | The kernel weights for the convolution. |
biasWeights | The bias weights for the convolution. Weights{} represents no bias. |
|
inlinenoexcept |
Add a multi-dimension convolution layer to the network.
input | The input tensor to the convolution. |
nbOutputMaps | The number of output feature maps for the convolution. |
kernelSize | The multi-dimensions of the convolution kernel. |
kernelWeights | The kernel weights for the convolution. |
biasWeights | The bias weights for the convolution. Weights{} represents no bias. |
|
inlinenoexcept |
Add a deconvolution layer to the network.
input | The input tensor to the layer. |
nbOutputMaps | The number of output feature maps. |
kernelSize | The HW-dimensions of the deconvolution kernel. |
kernelWeights | The kernel weights for the deconvolution. |
biasWeights | The bias weights for the deconvolution. Weights{} represents no bias. |
|
inlinenoexcept |
Add a multi-dimension deconvolution layer to the network.
input | The input tensor to the layer. |
nbOutputMaps | The number of output feature maps. |
kernelSize | The multi-dimensions of the deconvolution kernel. |
kernelWeights | The kernel weights for the deconvolution. |
biasWeights | The bias weights for the deconvolution. Weights{} represents no bias. |
|
inlinenoexcept |
Add a dequantization layer to the network.
input | The input tensor to be quantized. |
scale | A tensor with the scale value. |
input
tensor data type must be DataType::kFLOAT. scale
tensor data type must be DataType::kFLOAT. The subgraph which terminates with the scale
tensor must be a build-time constant.
|
inlinenoexcept |
Add an Einsum layer to the network.
inputs | The input tensors to the layer. |
nbInputs | The number of input tensors. |
equation | The equation of the layer |
|
inlinenoexcept |
Add an elementwise layer to the network.
input1 | The first input tensor to the layer. |
input2 | The second input tensor to the layer. |
op | The binary operation that the layer applies. |
The input tensors must have the same rank and compatible type. Two types are compatible if they are the same type or are both in the set {kFLOAT, kHALF}. For each dimension, their lengths must match, or one of them must be one. In the latter case, the tensor is broadcast along that axis.
The output tensor has the same rank as the inputs. For each dimension, its length is the maximum of the lengths of the corresponding input dimension.
The inputs are shape tensors if the output is a shape tensor.
|
inlinenoexcept |
Add a fill layer to the network.
dimensions | The output tensor dimensions. |
op | The fill operation that the layer applies. |
This layer is non-deterministic across subsequent calls as the same inputs will produce different output tensors if op
is either FillOperation::kRANDOM_UNIFORM or FillOperation::kRANDOM_NORMAL due to random state being shared across calls. The output tensors generated are determinstic when starting from the same initial state.
The network must not have an implicit batch dimension.
|
inlinenoexcept |
Add a fully connected layer to the network.
input | The input tensor to the layer. |
nbOutputs | The number of outputs of the layer. |
kernelWeights | The kernel weights for the fully connected layer. |
biasWeights | The bias weights for the fully connected layer. Weights{} represents no bias. |
|
inlinenoexcept |
Add gather with mode GatherMode::kDEFAULT and specified axis and nbElementWiseDims=0.
data | The tensor to gather values from. |
indices | The tensor to get indices from to populate the output tensor. |
axis | The axis in the data tensor to gather on. |
|
inlinenoexcept |
Add gather with specified mode, axis=0 and nbElementWiseDims=0.
data | The tensor to gather values from. |
indices | The tensor to get indices from to populate the output tensor. |
mode | The gather mode. |
|
inlinenoexcept |
Add a GridSample layer to the network.
input | The input tensor to the layer. |
grid | The grid tensor to the layer. |
Creates a GridSample layer with a InterpolationMode::kLINEAR, unaligned corners, and SampleMode::kFILL for 4d-shape input tensors.
|
inlinenoexcept |
Add an identity layer.
input | The input tensor to the layer. |
|
inlinenoexcept |
Add an If-conditional layer to the network.
An IIfConditional provides a way to conditionally execute parts of the network.
|
inlinenoexcept |
Add an input tensor to the network.
The name of the input tensor is used to find the index into the buffer array for an engine built from the network. The volume must be less than 2^31 elements.
For networks with an implicit batch dimension, this volume includes the batch dimension with its length set to the maximum batch size. For networks with all explicit dimensions and with wildcard dimensions, the volume is based on the maxima specified by an IOptimizationProfile.Dimensions are normally non-negative integers. The exception is that in networks with all explicit dimensions, -1 can be used as a wildcard for a dimension to be specified at runtime. Input tensors with such a wildcard must have a corresponding entry in the IOptimizationProfiles indicating the permitted extrema, and the input dimensions must be set by IExecutionContext::setBindingDimensions. Different IExecutionContext instances can have different dimensions. Wildcard dimensions are only supported for EngineCapability::kSTANDARD. They are not supported in safety contexts. DLA does not support Wildcard dimensions.
Tensor dimensions are specified independent of format. For example, if a tensor is formatted in "NHWC" or a vectorized format, the dimensions are still specified in the order{N, C, H, W}. For 2D images with a channel dimension, the last three dimensions are always {C,H,W}. For 3D images with a channel dimension, the last four dimensions are always {C,D,H,W}.
name | The name of the tensor. |
type | The type of the data held in the tensor. |
dimensions | The dimensions of the tensor. |
|
inlinenoexcept |
Add a loop to the network.
An ILoop provides a way to specify a recurrent subgraph.
The network must not have an implicit batch dimension.
|
inlinenoexcept |
Add a LRN layer to the network.
input | The input tensor to the layer. |
window | The size of the window. |
alpha | The alpha value for the LRN computation. |
beta | The beta value for the LRN computation. |
k | The k value for the LRN computation. |
|
inlinenoexcept |
Add a MatrixMultiply layer to the network.
input0 | The first input tensor (commonly A). |
op0 | The operation to apply to input0. |
input1 | The second input tensor (commonly B). |
op1 | The operation to apply to input1. |
The inputs are shape tensors if the output is a shape tensor.
|
inlinenoexcept |
Add a non-maximum suppression layer to the network.
boxes | The input boxes tensor to the layer. |
scores | The input scores tensor to the layer. |
maxOutputBoxesPerClass | The input maxOutputBoxesPerClass tensor to the layer. |
|
inlinenoexcept |
Add a nonzero layer to the network.
input | The input tensor to the layer. |
|
inlinenoexcept |
Add a normalization layer to the network.
input | The input tensor to the layer. |
scale | The scale tensor used to scale the normalized output. |
bias | The bias tensor used to scale the normalized output. |
axesMask | The axes on which to perform mean calculations. The bit in position i of bitmask axesMask corresponds to explicit dimension i of the result. E.g., the least significant bit corresponds to the first explicit dimension and the next to least significant bit corresponds to the second explicit dimension. |
The normalization layer works by performing normalization of the tensor input
on the specified axesMask
. The result is then scaled by multiplying with scale
and adding bias
.
The shape of scale
and bias
are expected the be the same, and must have the same rank and be unidirectionally broadcastable to the shape of input
.
|
inlinenoexcept |
Add a OneHot layer to the network.
indices | - tensor containing indices where on_value should be set. |
values | - a 2-element tensor, consisting of [off_value, on_value]. |
depth | - tensor containing the width of the added one-hot dimension. |
axis | - the axis to add the one-hot encoding to. |
|
inlinenoexcept |
Add a padding layer to the network.
input | The input tensor to the layer. |
prePadding | The padding to apply to the start of the tensor. |
postPadding | The padding to apply to the end of the tensor. |
|
inlinenoexcept |
Add a padding layer to the network. Only 2D padding is currently supported.
input | The input tensor to the layer. |
prePadding | The padding to apply to the start of the tensor. |
postPadding | The padding to apply to the end of the tensor. |
|
inlinenoexcept |
Add a parametric ReLU layer to the network.
input | The input tensor to the layer. |
slope | The slope tensor to the layer. This tensor should be unidirectionally broadcastable to the input tensor. |
|
inlinenoexcept |
Add a plugin layer to the network using the IPluginV2 interface.
inputs | The input tensors to the layer. |
nbInputs | The number of input tensors. |
plugin | The layer plugin. |
|
inlinenoexcept |
Add a pooling layer to the network.
input | The input tensor to the layer. |
type | The type of pooling to apply. |
windowSize | The size of the pooling window. |
|
inlinenoexcept |
Add a multi-dimension pooling layer to the network.
input | The input tensor to the layer. |
type | The type of pooling to apply. |
windowSize | The size of the pooling window. |
|
inlinenoexcept |
Add a quantization layer to the network.
input | The input tensor to be quantized. |
scale | A tensor with the scale value. |
input
tensor data type must be DataType::kFLOAT. scale
tensor data type must be DataType::kFLOAT. The subgraph which terminates with the scale
tensor must be a build-time constant.
|
inlinenoexcept |
Add a RaggedSoftMax layer to the network.
input | The ZxS input tensor. |
bounds | The Zx1 bounds tensor. |
|
inlinenoexcept |
Add a reduce layer to the network.
input | The input tensor to the layer. |
operation | The reduction operation to perform. |
reduceAxes | The reduction dimensions. The bit in position i of bitmask reduceAxes corresponds to explicit dimension i if result. E.g., the least significant bit corresponds to the first explicit dimension and the next to least significant bit corresponds to the second explicit dimension. |
keepDimensions | The boolean that specifies whether or not to keep the reduced dimensions in the output of the layer. |
The reduce layer works by performing an operation specified by operation
to reduce the tensor input
across the axes specified by reduceAxes
.
|
inlinenoexcept |
Add a resize layer to the network.
input | The input tensor to the layer. |
|
inlinenoexcept |
Add a ReverseSequence layer to the network.
input | The input tensor to the layer. Must have rank >= 2. |
sequenceLens | 1D tensor specifying lengths of sequences to reverse in a batch. The length of the sequenceLens tensor must be equal to the size of the dimension in input tensor specified by batchAxis. |
|
inlinenoexcept |
Add an layerCount
deep RNN layer to the network with hiddenSize
internal states that can take a batch with fixed or variable sequence lengths.
input | The input tensor to the layer (see below). |
layerCount | The number of layers in the RNN. |
hiddenSize | Size of the internal hidden state for each layer. |
maxSeqLen | Maximum sequence length for the input. |
op | The type of RNN to execute. |
By default, the layer is configured with RNNDirection::kUNIDIRECTION and RNNInputMode::kLINEAR. To change these settings, use IRNNv2Layer::setDirection() and IRNNv2Layer::setInputMode().
Weights and biases for the added layer should be set using IRNNv2Layer::setWeightsForGate() and IRNNv2Layer::setBiasForGate() prior to building an engine using this network.
The input tensors must be of the type DataType::kFLOAT or DataType::kHALF. The layout of the weights is row major and must be the same datatype as the input tensor. weights
contain 8 matrices and bias
contains 8 vectors.
See IRNNv2Layer::setWeightsForGate() and IRNNv2Layer::setBiasForGate() for details on the required input format for weights
and bias
.
The input
ITensor should contain zero or more index dimensions {N1, ..., Np}
, followed by two dimensions, defined as follows:
S_max
is the maximum allowed sequence length (number of RNN iterations)E
specifies the embedding length (unless RNNInputMode::kSKIP is set, in which case it should match getHiddenSize()).By default, all sequences in the input are assumed to be size maxSeqLen
. To provide explicit sequence lengths for each input sequence in the batch, use IRNNv2Layer::setSequenceLengths().
The RNN layer outputs up to three tensors.
The first output tensor is the output of the final RNN layer across all timesteps, with dimensions {N1, ..., Np, S_max, H}
:
N1..Np
are the index dimensions specified by the input tensorS_max
is the maximum allowed sequence length (number of RNN iterations)H
is an output hidden state (equal to getHiddenSize() or 2x getHiddenSize())The second tensor is the final hidden state of the RNN across all layers, and if the RNN is an LSTM (i.e. getOperation() is RNNOperation::kLSTM), then the third tensor is the final cell state of the RNN across all layers. Both the second and third output tensors have dimensions {N1, ..., Np, L, H}
:
N1..Np
are the index dimensions specified by the input tensorL
is the number of layers in the RNN, equal to getLayerCount() if getDirection is RNNDirection::kUNIDIRECTION, and 2x getLayerCount() if getDirection is RNNDirection::kBIDIRECTION. In the bi-directional case, layer l
's final forward hidden state is stored in L = 2*l
, and final backward hidden state is stored in L= 2*l + 1
.H
is the hidden state for each layer, equal to getHiddenSize().
|
inlinenoexcept |
Add a Scale layer to the network.
input | The input tensor to the layer. This tensor is required to have a minimum of 3 dimensions in implicit batch mode and a minimum of 4 dimensions in explicit batch mode. |
mode | The scaling mode. |
shift | The shift value. |
scale | The scale value. |
power | The power value. |
If the weights are available, then the size of weights are dependent on the ScaleMode. For ScaleMode::kUNIFORM, the number of weights equals 1. For ScaleMode::kCHANNEL, the number of weights equals the channel dimension. For ScaleMode::kELEMENTWISE, the number of weights equals the product of the last three dimensions of the input.
|
inlinenoexcept |
Add a multi-dimension scale layer to the network.
input | The input tensor to the layer. |
mode | The scaling mode. |
shift | The shift value. |
scale | The scale value. |
power | The power value. |
channelAxis | The channel axis. |
If the weights are available, then the size of weights are dependent on the ScaleMode. For ScaleMode::kUNIFORM, the number of weights equals 1. For ScaleMode::kCHANNEL, the number of weights equals the channel dimension. For ScaleMode::kELEMENTWISE, the number of weights equals the product of all input dimensions at channelAxis and beyond.
For example, if the inputs dimensions are [A,B,C,D,E,F], and channelAxis=2: For ScaleMode::kUNIFORM, the number of weights is equal to 1. For ScaleMode::kCHANNEL, the number of weights is C. For ScaleMode::kELEMENTWISE, the number of weights is C*D*E*F.
channelAxis can also be set explicitly using setChannelAxis().
|
inlinenoexcept |
Add a Scatter layer to the network with specified mode and axis=0.
data | The input tensor to be updated with additional values. |
indices | indices of the elements to be updated. |
updates | values to be used for updates. |
mode | scatter mode. |
indices
tensor data type must be DataType::kINT32. updates
tensor data type must be the same as data
|
inlinenoexcept |
Add a select layer to the network.
condition | The condition tensor to the layer. Must have type DataType::kBOOL. |
thenInput | The "then" input tensor to the layer. |
elseInput | The "else" input tensor to the layer. |
All three input tensors must have the same rank, and along each axis must have the same length or a length of one. If the length is one, the tensor is broadcast along that axis. The output tensor has the dimensions of the inputs AFTER the broadcast rule is applied. For example, given:
dimensions of condition: [1,1,5,9] dimensions of thenInput: [1,1,5,9] dimensions of elseInput: [1,3,1,9]
the output dimensions are [1,3,5,9], and the output contents are defined by:
output[0,i,j,k] = condition[0,0,j,k] ? thenInput[0,0,j,k] : elseInput[0,i,0,k]
The output dimensions are not necessarily the max of the input dimensions if any input is an empty tensor. For example, if in the preceding example, 5 is changed to 0:
dimensions of condition: [1,1,0,9] dimensions of thenInput: [1,1,0,9] dimensions of elseInput: [1,3,1,9]
then the output dimensions are [1,3,0,9].
The network must not have an implicit batch dimension.
The inputs are shape tensors if the output is a shape tensor.
|
inlinenoexcept |
Add a shape layer to the network.
input | The input tensor to the layer. |
|
inlinenoexcept |
Add a shuffle layer to the network.
input | The input tensor to the layer. |
|
inlinenoexcept |
Add a slice layer to the network.
input | The input tensor to the layer. |
start | The start offset |
size | The output dimension |
stride | The slicing stride |
Positive, negative, zero stride values, and combinations of them in different dimensions are allowed.
|
inlinenoexcept |
Add a SoftMax layer to the network.
|
inlinenoexcept |
Add a TopK layer to the network.
The TopK layer has two outputs of the same dimensions. The first contains data values, the second contains index positions for the values. Output values are sorted, largest first for operation kMAX and smallest first for operation kMIN.
Currently only values of K up to 3840 are supported.
input | The input tensor to the layer. |
op | Operation to perform. |
k | The number of elements to keep. For dynamic k, use the setInput() method to pass in k as a tensor instead, which will override the static k value passed here in calculations. |
reduceAxes | The reduction dimensions. The bit in position i of bitmask reduceAxes corresponds to explicit dimension i of the result. E.g., the least significant bit corresponds to the first explicit dimension and the next to least significant bit corresponds to the second explicit dimension. |
Currently reduceAxes must specify exactly one dimension, and it must be one of the last four dimensions.
|
inlinenoexcept |
Add a unary layer to the network.
input | The input tensor to the layer. |
operation | The operation to apply. |
Generally the input must have a floating-point type (or kINT8 as a quantized float), except for the following operations:
The input is a shape tensor if the output is a shape tensor.
|
inlinenoexcept |
Destroy this INetworkDefinition object.
delete
.
|
inlinevirtualnoexcept |
Return the builder from which this INetworkDefinition was created.
|
inlinenoexcept |
get the ErrorRecorder assigned to this interface.
Retrieves the assigned error recorder object for the given class. A nullptr will be returned if setErrorRecorder has not been called.
|
inlinenoexcept |
Get the input tensor specified by the given index.
index | The index of the input tensor. |
|
inlinenoexcept |
Get the layer specified by the given index.
index | The index of the layer. |
|
inlinenoexcept |
Returns the name associated with the network.
The memory pointed to by getName() is owned by the INetworkDefinition object.
|
inlinenoexcept |
Get the number of inputs in the network.
|
inlinenoexcept |
Get the number of layers in the network.
|
inlinenoexcept |
Get the number of outputs in the network.
The outputs include those marked by markOutput or markOutputForShapes.
|
inlinenoexcept |
Get the output tensor specified by the given index.
index | The index of the output tensor. |
|
inlinenoexcept |
True if network is an explicit precision network.
|
inlinenoexcept |
Query whether the network was created with an implicit batch dimension.
This is a network-wide property. Either all tensors in the network have an implicit batch dimension or none of them do.
hasImplicitBatchDimension() is true if and only if this INetworkDefinition was created with createNetworkV2() without NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag.
|
inlinenoexcept |
Mark a tensor as a network output.
tensor | The tensor to mark as an output tensor. |
|
inlinenoexcept |
Enable tensor's value to be computed by IExecutionContext::getShapeBinding.
The tensor must be of type DataType::kINT32 and have no more than one dimension.
|
inlinenoexcept |
remove a tensor from the network definition.
tensor | the tensor to remove |
It is illegal to remove a tensor that is the input or output of a layer. if this method is called with such a tensor, a warning will be emitted on the log and the call will be ignored. Its intended use is to remove detached tensors after e.g. concatenating two networks with Layer::setInput().
|
inlinenoexcept |
Set the ErrorRecorder for this interface.
Assigns the ErrorRecorder to this interface. The ErrorRecorder will track all errors during execution. This function will call incRefCount of the registered ErrorRecorder at least once. Setting recorder to nullptr unregisters the recorder with the interface, resulting in a call to decRefCount if a recorder has been registered.
If an error recorder is not set, messages will be sent to the global log stream.
recorder | The error recorder to register with this interface. |
|
inlinenoexcept |
Sets the name of the network.
name | The name to assign to this network. |
Set the name of the network so that it can be associated with a built engine. The name
must be a null-terminated C-style string. TensorRT makes no use of this string except storing it as part of the engine so that it may be retrieved at runtime. A name unique to the builder will be generated by default.
This method copies the name string.
|
inlinenoexcept |
Associate a name with all current uses of the given weights.
The name must be set after the Weights are used in the network. Lookup is associative. The name applies to all Weights with matching type, value pointer, and count. If Weights with a matching value pointer, but different type or count exists in the network, an error message is issued, the name is rejected, and return false. If the name has already been used for other weights, return false. A nullptr causes the weights to become unnamed, i.e. clears any previous name.
weights | The weights to be named. |
name | The name to associate with the weights. |
|
inlinenoexcept |
unmark a tensor as a network output.
tensor | The tensor to unmark as an output tensor. |
see markOutput()
|
inlinenoexcept |
Undo markOutputForShapes.
|
protected |