|
virtual ITensor * | addInput (const char *name, DataType type, Dims dimensions)=0 |
| Add an input tensor to the network. More...
|
|
virtual void | markOutput (ITensor &tensor)=0 |
| Mark a tensor as a network output. More...
|
|
virtual IConvolutionLayer * | addConvolution (ITensor &input, int nbOutputMaps, DimsHW kernelSize, Weights kernelWeights, Weights biasWeights)=0 |
| Add a convolution layer to the network. More...
|
|
virtual IFullyConnectedLayer * | addFullyConnected (ITensor &input, int nbOutputs, Weights kernelWeights, Weights biasWeights)=0 |
| Add a fully connected layer to the network. More...
|
|
virtual IActivationLayer * | addActivation (ITensor &input, ActivationType type)=0 |
| Add an activation layer to the network. More...
|
|
virtual IPoolingLayer * | addPooling (ITensor &input, PoolingType type, DimsHW windowSize)=0 |
| Add a pooling layer to the network. More...
|
|
virtual ILRNLayer * | addLRN (ITensor &input, int window, float alpha, float beta, float k)=0 |
| Add a LRN layer to the network. More...
|
|
virtual IScaleLayer * | addScale (ITensor &input, ScaleMode mode, Weights shift, Weights scale, Weights power)=0 |
| Add a Scale layer to the network. More...
|
|
virtual ISoftMaxLayer * | addSoftMax (ITensor &input)=0 |
| Add a SoftMax layer to the network. More...
|
|
virtual IConcatenationLayer * | addConcatenation (ITensor *const *inputs, int nbInputs)=0 |
| Add a concatenation layer to the network. More...
|
|
virtual IDeconvolutionLayer * | addDeconvolution (ITensor &input, int nbOutputMaps, DimsHW kernelSize, Weights kernelWeights, Weights biasWeights)=0 |
| Add a deconvolution layer to the network. More...
|
|
virtual IElementWiseLayer * | addElementWise (ITensor &input1, ITensor &input2, ElementWiseOperation op)=0 |
| Add an elementwise layer to the network. More...
|
|
virtual IRNNLayer * | addRNN (ITensor &inputs, int layerCount, std::size_t hiddenSize, int maxSeqLen, RNNOperation op, RNNInputMode mode, RNNDirection dir, Weights weights, Weights bias)=0 |
| Add an layerCount deep RNN layer to the network with a sequence length of maxSeqLen and hiddenSize internal state per layer. More...
|
|
virtual IPluginLayer * | addPlugin (ITensor *const *inputs, int nbInputs, IPlugin &plugin)=0 |
| Add a plugin layer to the network. More...
|
|
virtual IUnaryLayer * | addUnary (ITensor &input, UnaryOperation operation)=0 |
| Add a unary layer to the network. More...
|
|
virtual IPaddingLayer * | addPadding (ITensor &input, DimsHW prePadding, DimsHW postPadding)=0 |
| Add a padding layer to the network. More...
|
|
virtual IShuffleLayer * | addShuffle (ITensor &input)=0 |
| Add a shuffle layer to the network. More...
|
|
virtual void | setPoolingOutputDimensionsFormula (IOutputDimensionsFormula *formula)=0 |
| Set the pooling output dimensions formula. More...
|
|
virtual IOutputDimensionsFormula & | getPoolingOutputDimensionsFormula () const =0 |
| Get the pooling output dimensions formula. More...
|
|
virtual void | setConvolutionOutputDimensionsFormula (IOutputDimensionsFormula *formula)=0 |
| Set the convolution output dimensions formula. More...
|
|
virtual IOutputDimensionsFormula & | getConvolutionOutputDimensionsFormula () const =0 |
| Get the convolution output dimensions formula. More...
|
|
virtual void | setDeconvolutionOutputDimensionsFormula (IOutputDimensionsFormula *formula)=0 |
| Set the deconvolution output dimensions formula. More...
|
|
virtual IOutputDimensionsFormula & | getDeconvolutionOutputDimensionsFormula () const =0 |
| Get the deconvolution output dimensions formula. More...
|
|
virtual int | getNbLayers () const =0 |
| Get the number of layers in the network. More...
|
|
virtual ILayer * | getLayer (int index) const =0 |
| Get the layer specified by the given index. More...
|
|
virtual int | getNbInputs () const =0 |
| Get the number of inputs in the network. More...
|
|
virtual ITensor * | getInput (int index) const =0 |
| Get the input tensor specified by the given index. More...
|
|
virtual int | getNbOutputs () const =0 |
| Get the number of outputs in the network. More...
|
|
virtual ITensor * | getOutput (int index) const =0 |
| Get the output tensor specified by the given index. More...
|
|
virtual void | destroy ()=0 |
| Destroy this INetworkDefinition object.
|
|
virtual IReduceLayer * | addReduce (ITensor &input, ReduceOperation operation, uint32_t reduceAxes, bool keepDimensions)=0 |
| Add a reduce layer to the network. More...
|
|
virtual ITopKLayer * | addTopK (ITensor &input, TopKOperation op, int k, uint32_t reduceAxes)=0 |
| Add a TopK layer to the network. More...
|
|
virtual IGatherLayer * | addGather (ITensor &data, ITensor &indices, int axis)=0 |
| Add a gather layer to the network. More...
|
|
virtual IRaggedSoftMaxLayer * | addRaggedSoftMax (ITensor &input, ITensor &bounds)=0 |
| Add a RaggedSoftMax layer to the network. More...
|
|
virtual IMatrixMultiplyLayer * | addMatrixMultiply (ITensor &input0, MatrixOperation op0, ITensor &input1, MatrixOperation op1)=0 |
| Add a MatrixMultiply layer to the network. More...
|
|
virtual IMatrixMultiplyLayer * | addMatrixMultiply (ITensor &input0, bool transpose0, ITensor &input1, bool transpose1)=0 |
| Add a MatrixMultiply layer to the network. More...
|
|
virtual IConstantLayer * | addConstant (Dims dimensions, Weights weights)=0 |
| Add a constant layer to the network. More...
|
|
virtual IRNNv2Layer * | addRNNv2 (ITensor &input, int32_t layerCount, int32_t hiddenSize, int32_t maxSeqLen, RNNOperation op)=0 |
| 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...
|
|
virtual IPluginLayer * | addPluginExt (ITensor *const *inputs, int nbInputs, IPluginExt &plugin)=0 |
| Add a plugin layer to the network using an IPluginExt interface. More...
|
|
virtual IIdentityLayer * | addIdentity (ITensor &input)=0 |
| Add an identity layer. More...
|
|
virtual void | removeTensor (ITensor &tensor)=0 |
| remove a tensor from the network definition. More...
|
|
virtual void | unmarkOutput (ITensor &tensor)=0 |
| unmark a tensor as a network output. More...
|
|
virtual IPluginV2Layer * | addPluginV2 (ITensor *const *inputs, int nbInputs, IPluginV2 &plugin)=0 |
| Add a plugin layer to the network using the IPluginV2 interface. More...
|
|
A network definition for input to the builder.
Add an layerCount
deep RNN layer to the network with a sequence length of maxSeqLen
and hiddenSize
internal state per layer.
- Parameters
-
inputs | The input tensor to the layer. |
layerCount | The number of layers in the RNN. |
hiddenSize | The size of the internal hidden state for each layer. |
maxSeqLen | The maximum length of the time sequence. |
op | The type of RNN to execute. |
mode | The input mode for the RNN. |
dir | The direction to run the RNN. |
weights | The weights for the weight matrix parameters of the RNN. |
bias | The weights for the bias vectors parameters of the RNN. |
The input tensors must be of the type DataType::kFLOAT or DataType::kHALF.
See IRNNLayer::setWeights() and IRNNLayer::setBias() for details on the required input format for weights
and bias
.
The layout for the input
tensor should be {1, S_max, N, E}
, where:
S_max
is the maximum allowed sequence length (number of RNN iterations)
N
is the batch size
E
specifies the embedding length (unless kSKIP is set, in which case it should match getHiddenSize()).
The first output tensor is the output of the final RNN layer across all timesteps, with dimensions {S_max, N, H}
:
S_max
is the maximum allowed sequence length (number of RNN iterations)
N
is the batch size
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 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 {L, N, H}
:
L
is equal to getLayerCount() if getDirection is kUNIDIRECTION, and 2*getLayerCount() if getDirection is 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
.
N
is the batch size
H
is getHiddenSize().
Note that in bidirectional RNNs, the full "hidden state" for a layer l
is the concatenation of its forward hidden state and its backward hidden state, and its size is 2*H.
- Deprecated:
- IRNNLayer is superseded by IRNNv2Layer. Use addRNNv2() instead.
- Returns
- The new RNN layer, or null if it could not be created.
- See Also
- IRNNLayer
virtual IRNNv2Layer* nvinfer1::INetworkDefinition::addRNNv2 |
( |
ITensor & |
input, |
|
|
int32_t |
layerCount, |
|
|
int32_t |
hiddenSize, |
|
|
int32_t |
maxSeqLen, |
|
|
RNNOperation |
op |
|
) |
| |
|
pure virtual |
Add an layerCount
deep RNN layer to the network with hiddenSize
internal states that can take a batch with fixed or variable sequence lengths.
- Parameters
-
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 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 tensor
S_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 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 tensor
L
is the number of layers in the RNN, equal to getLayerCount()
H
is the hidden state for each layer, equal to getHiddenSize() if getDirection is kUNIDIRECTION, and 2x getHiddenSize() otherwise.
- Returns
- The new RNN layer, or null if it could not be created.
- See Also
- IRNNv2Layer