TensorRT  5.1.3.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
nvinfer1::INetworkDefinition Class Referenceabstract

A network definition for input to the builder. More...

#include <NvInfer.h>

Public Member Functions

virtual ITensoraddInput (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 IConvolutionLayeraddConvolution (ITensor &input, int nbOutputMaps, DimsHW kernelSize, Weights kernelWeights, Weights biasWeights)=0
 Add a convolution layer to the network. More...
 
virtual IFullyConnectedLayeraddFullyConnected (ITensor &input, int nbOutputs, Weights kernelWeights, Weights biasWeights)=0
 Add a fully connected layer to the network. More...
 
virtual IActivationLayeraddActivation (ITensor &input, ActivationType type)=0
 Add an activation layer to the network. More...
 
virtual IPoolingLayeraddPooling (ITensor &input, PoolingType type, DimsHW windowSize)=0
 Add a pooling layer to the network. More...
 
virtual ILRNLayeraddLRN (ITensor &input, int window, float alpha, float beta, float k)=0
 Add a LRN layer to the network. More...
 
virtual IScaleLayeraddScale (ITensor &input, ScaleMode mode, Weights shift, Weights scale, Weights power)=0
 Add a Scale layer to the network. More...
 
virtual ISoftMaxLayeraddSoftMax (ITensor &input)=0
 Add a SoftMax layer to the network. More...
 
virtual IConcatenationLayeraddConcatenation (ITensor *const *inputs, int nbInputs)=0
 Add a concatenation layer to the network. More...
 
virtual IDeconvolutionLayeraddDeconvolution (ITensor &input, int nbOutputMaps, DimsHW kernelSize, Weights kernelWeights, Weights biasWeights)=0
 Add a deconvolution layer to the network. More...
 
virtual IElementWiseLayeraddElementWise (ITensor &input1, ITensor &input2, ElementWiseOperation op)=0
 Add an elementwise layer to the network. More...
 
virtual IRNNLayeraddRNN (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 IPluginLayeraddPlugin (ITensor *const *inputs, int nbInputs, IPlugin &plugin)=0
 Add a plugin layer to the network. More...
 
virtual IUnaryLayeraddUnary (ITensor &input, UnaryOperation operation)=0
 Add a unary layer to the network. More...
 
virtual IPaddingLayeraddPadding (ITensor &input, DimsHW prePadding, DimsHW postPadding)=0
 Add a padding layer to the network. More...
 
virtual IShuffleLayeraddShuffle (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 IOutputDimensionsFormulagetPoolingOutputDimensionsFormula () const =0
 Get the pooling output dimensions formula. More...
 
virtual void setConvolutionOutputDimensionsFormula (IOutputDimensionsFormula *formula)=0
 Set the convolution output dimensions formula. More...
 
virtual IOutputDimensionsFormulagetConvolutionOutputDimensionsFormula () const =0
 Get the convolution output dimensions formula. More...
 
virtual void setDeconvolutionOutputDimensionsFormula (IOutputDimensionsFormula *formula)=0
 Set the deconvolution output dimensions formula. More...
 
virtual IOutputDimensionsFormulagetDeconvolutionOutputDimensionsFormula () const =0
 Get the deconvolution output dimensions formula. More...
 
virtual int getNbLayers () const =0
 Get the number of layers in the network. More...
 
virtual ILayergetLayer (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 ITensorgetInput (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 ITensorgetOutput (int index) const =0
 Get the output tensor specified by the given index. More...
 
virtual void destroy ()=0
 Destroy this INetworkDefinition object.
 
virtual IReduceLayeraddReduce (ITensor &input, ReduceOperation operation, uint32_t reduceAxes, bool keepDimensions)=0
 Add a reduce layer to the network. More...
 
virtual ITopKLayeraddTopK (ITensor &input, TopKOperation op, int k, uint32_t reduceAxes)=0
 Add a TopK layer to the network. More...
 
virtual IGatherLayeraddGather (ITensor &data, ITensor &indices, int axis)=0
 Add a gather layer to the network. More...
 
virtual IRaggedSoftMaxLayeraddRaggedSoftMax (ITensor &input, ITensor &bounds)=0
 Add a RaggedSoftMax layer to the network. More...
 
virtual IMatrixMultiplyLayeraddMatrixMultiply (ITensor &input0, MatrixOperation op0, ITensor &input1, MatrixOperation op1)=0
 Add a MatrixMultiply layer to the network. More...
 
virtual IMatrixMultiplyLayeraddMatrixMultiply (ITensor &input0, bool transpose0, ITensor &input1, bool transpose1)=0
 Add a MatrixMultiply layer to the network. More...
 
virtual IConstantLayeraddConstant (Dims dimensions, Weights weights)=0
 Add a constant layer to the network. More...
 
virtual IRNNv2LayeraddRNNv2 (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 IPluginLayeraddPluginExt (ITensor *const *inputs, int nbInputs, IPluginExt &plugin)=0
 Add a plugin layer to the network using an IPluginExt interface. More...
 
virtual IIdentityLayeraddIdentity (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 IPluginV2LayeraddPluginV2 (ITensor *const *inputs, int nbInputs, IPluginV2 &plugin)=0
 Add a plugin layer to the network using the IPluginV2 interface. More...
 
virtual ISliceLayeraddSlice (ITensor &input, Dims start, Dims size, Dims stride)=0
 Add a slice layer to the network. More...
 

Detailed Description

A network definition for input to the builder.

Warning
Do not inherit from this class, as doing so will break forward-compatibility of the API and ABI.

Member Function Documentation

virtual IActivationLayer* nvinfer1::INetworkDefinition::addActivation ( ITensor input,
ActivationType  type 
)
pure virtual

Add an activation layer to the network.

Parameters
inputThe input tensor to the layer.
typeThe 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.

See Also
IActivationLayer ActivationType
Returns
The new activation layer, or nullptr if it could not be created.
virtual IConcatenationLayer* nvinfer1::INetworkDefinition::addConcatenation ( ITensor *const *  inputs,
int  nbInputs 
)
pure virtual

Add a concatenation layer to the network.

Parameters
inputsThe input tensors to the layer.
nbInputsThe number of input tensors.
See Also
IConcatenationLayer
Returns
The new concatenation layer, or nullptr if it could not be created.
Warning
All tensors must have the same dimensions for all dimensions except for channel.
virtual IConstantLayer* nvinfer1::INetworkDefinition::addConstant ( Dims  dimensions,
Weights  weights 
)
pure virtual

Add a constant layer to the network.

Parameters
dimensionsThe dimensions of the constant.
weightsThe constant value, represented as weights.
See Also
IConstantLayer
Returns
The new constant layer, or nullptr if it could not be created.

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 FP32, FP16, or quantized INT8 following TensorRT's normal precision rules.

virtual IConvolutionLayer* nvinfer1::INetworkDefinition::addConvolution ( ITensor input,
int  nbOutputMaps,
DimsHW  kernelSize,
Weights  kernelWeights,
Weights  biasWeights 
)
pure virtual

Add a convolution layer to the network.

Parameters
inputThe input tensor to the convolution.
nbOutputMapsThe number of output feature maps for the convolution.
kernelSizeThe HW-dimensions of the convolution kernel.
kernelWeightsThe kernel weights for the convolution.
biasWeightsThe optional bias weights for the convolution.
See Also
IConvolutionLayer
Returns
The new convolution layer, or nullptr if it could not be created.
virtual IDeconvolutionLayer* nvinfer1::INetworkDefinition::addDeconvolution ( ITensor input,
int  nbOutputMaps,
DimsHW  kernelSize,
Weights  kernelWeights,
Weights  biasWeights 
)
pure virtual

Add a deconvolution layer to the network.

Parameters
inputThe input tensor to the layer.
nbOutputMapsThe number of output feature maps.
kernelSizeThe HW-dimensions of the convolution kernel.
kernelWeightsThe kernel weights for the convolution.
biasWeightsThe optional bias weights for the convolution.
See Also
IDeconvolutionLayer
Returns
The new deconvolution layer, or nullptr if it could not be created.
virtual IElementWiseLayer* nvinfer1::INetworkDefinition::addElementWise ( ITensor input1,
ITensor input2,
ElementWiseOperation  op 
)
pure virtual

Add an elementwise layer to the network.

Parameters
input1The first input tensor to the layer.
input2The second input tensor to the layer.
opThe binary operation that the layer applies.

The input tensors must have the same number of dimensions. 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 number of dimensions as the inputs. For each dimension, its length is the maximum of the lengths of the corresponding input dimension.

See Also
IElementWiseLayer
Returns
The new elementwise layer, or nullptr if it could not be created.
virtual IFullyConnectedLayer* nvinfer1::INetworkDefinition::addFullyConnected ( ITensor input,
int  nbOutputs,
Weights  kernelWeights,
Weights  biasWeights 
)
pure virtual

Add a fully connected layer to the network.

Parameters
inputThe input tensor to the layer.
nbOutputsThe number of outputs of the layer.
kernelWeightsThe kernel weights for the convolution.
biasWeightsThe optional bias weights for the convolution.
See Also
IFullyConnectedLayer
Returns
The new fully connected layer, or nullptr if it could not be created.
virtual IGatherLayer* nvinfer1::INetworkDefinition::addGather ( ITensor data,
ITensor indices,
int  axis 
)
pure virtual

Add a gather layer to the network.

Parameters
dataThe tensor to gather values from.
indicesThe tensor to get indices from to populate the output tensor.
axisThe non-batch dimension axis in the data tensor to gather on.
See Also
IGatherLayer
Returns
The new gather layer, or nullptr if it could not be created.
virtual IIdentityLayer* nvinfer1::INetworkDefinition::addIdentity ( ITensor input)
pure virtual

Add an identity layer.

Parameters
inputThe input tensor to the layer.
See Also
IIdentityLayer
Returns
The new identity layer, or nullptr if it could not be created.
virtual ITensor* nvinfer1::INetworkDefinition::addInput ( const char *  name,
DataType  type,
Dims  dimensions 
)
pure virtual

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.

Parameters
nameThe name of the tensor.
typeThe type of the data held in the tensor.
dimensionsThe dimensions of the tensor.

Only DataType::kFLOAT, DataType::kHALF and DataType::kINT32 are valid input tensor types. The volume of the dimensions, including the maximum batch size, must be less than 2^30 elements.

See Also
ITensor
Returns
The new tensor or nullptr if there is an error.
virtual ILRNLayer* nvinfer1::INetworkDefinition::addLRN ( ITensor input,
int  window,
float  alpha,
float  beta,
float  k 
)
pure virtual

Add a LRN layer to the network.

Parameters
inputThe input tensor to the layer.
windowThe size of the window.
alphaThe alpha value for the LRN computation.
betaThe beta value for the LRN computation.
kThe k value for the LRN computation.
See Also
ILRNLayer
Returns
The new LRN layer, or nullptr if it could not be created.
virtual IMatrixMultiplyLayer* nvinfer1::INetworkDefinition::addMatrixMultiply ( ITensor input0,
MatrixOperation  op0,
ITensor input1,
MatrixOperation  op1 
)
pure virtual

Add a MatrixMultiply layer to the network.

Parameters
input0The first input tensor (commonly A).
op0The operation to apply to input0.
input1The second input tensor (commonly B).
op1The operation to apply to input1.
See Also
IMatrixMultiplyLayer
Returns
The new matrix multiply layer, or nullptr if it could not be created.
virtual IMatrixMultiplyLayer* nvinfer1::INetworkDefinition::addMatrixMultiply ( ITensor input0,
bool  transpose0,
ITensor input1,
bool  transpose1 
)
pure virtual

Add a MatrixMultiply layer to the network.

Parameters
input0The first input tensor (commonly A).
transpose0If true, op(input0)=transpose(input0), else op(input0)=input0.
input1The second input tensor (commonly B).
transpose1If true, op(input1)=transpose(input1), else op(input1)=input1.
See Also
IMatrixMultiplyLayer
Returns
The new matrix multiply layer, or nullptr if it could not be created.
Deprecated:
This interface is superseded by the overload that replaces bool with MatrixOperation.
virtual IPaddingLayer* nvinfer1::INetworkDefinition::addPadding ( ITensor input,
DimsHW  prePadding,
DimsHW  postPadding 
)
pure virtual

Add a padding layer to the network.

Parameters
inputThe input tensor to the layer.
prePaddingThe padding to apply to the start of the tensor.
postPaddingThe padding to apply to the end of the tensor.
See Also
IPaddingLayer
Returns
The new padding layer, or nullptr if it could not be created.
virtual IPluginLayer* nvinfer1::INetworkDefinition::addPlugin ( ITensor *const *  inputs,
int  nbInputs,
IPlugin plugin 
)
pure virtual

Add a plugin layer to the network.

Parameters
inputsThe input tensors to the layer.
nbInputsThe number of input tensors.
pluginThe layer plugin.
See Also
IPluginLayer
Returns
the new plugin layer, or nullptr if it could not be created.
virtual IPluginLayer* nvinfer1::INetworkDefinition::addPluginExt ( ITensor *const *  inputs,
int  nbInputs,
IPluginExt plugin 
)
pure virtual

Add a plugin layer to the network using an IPluginExt interface.

Parameters
inputsThe input tensors to the layer.
nbInputsThe number of input tensors.
pluginThe layer plugin.
See Also
IPluginLayer
Returns
The new plugin layer, or nullptr if it could not be created.
virtual IPluginV2Layer* nvinfer1::INetworkDefinition::addPluginV2 ( ITensor *const *  inputs,
int  nbInputs,
IPluginV2 plugin 
)
pure virtual

Add a plugin layer to the network using the IPluginV2 interface.

Parameters
inputsThe input tensors to the layer.
nbInputsThe number of input tensors.
pluginThe layer plugin.
See Also
IPluginV2Layer
Returns
The new plugin layer, or nullptr if it could not be created.
virtual IPoolingLayer* nvinfer1::INetworkDefinition::addPooling ( ITensor input,
PoolingType  type,
DimsHW  windowSize 
)
pure virtual

Add a pooling layer to the network.

Parameters
inputThe input tensor to the layer.
typeThe type of pooling to apply.
windowSizeThe size of the pooling window.
See Also
IPoolingLayer PoolingType
Returns
The new pooling layer, or nullptr if it could not be created.
virtual IRaggedSoftMaxLayer* nvinfer1::INetworkDefinition::addRaggedSoftMax ( ITensor input,
ITensor bounds 
)
pure virtual

Add a RaggedSoftMax layer to the network.

Parameters
inputThe ZxS input tensor.
boundsThe Zx1 bounds tensor.
See Also
IRaggedSoftMaxLayer
Returns
The new RaggedSoftMax layer, or nullptr if it could not be created.
virtual IReduceLayer* nvinfer1::INetworkDefinition::addReduce ( ITensor input,
ReduceOperation  operation,
uint32_t  reduceAxes,
bool  keepDimensions 
)
pure virtual

Add a reduce layer to the network.

Parameters
inputThe input tensor to the layer.
operationThe reduction operation to perform.
reduceAxesThe reduction dimensions. Bit 0 of the uint32_t type corresponds to the non-batch dimension 0 boolean and so on. If a bit is set, then the corresponding dimension will be reduced. Let's say we have an NCHW tensor as input (three non-batch dimensions). Bit 0 corresponds to the C dimension boolean. Bit 1 corresponds to the H dimension boolean. Bit 2 corresponds to the W dimension boolean. Note that reduction is not permitted over the batch size dimension.
keepDimensionsThe boolean that specifies whether or not to keep the reduced dimensions in the output of the layer.
See Also
IReduceLayer
Returns
The new reduce layer, or nullptr if it could not be created.
virtual IRNNLayer* nvinfer1::INetworkDefinition::addRNN ( ITensor inputs,
int  layerCount,
std::size_t  hiddenSize,
int  maxSeqLen,
RNNOperation  op,
RNNInputMode  mode,
RNNDirection  dir,
Weights  weights,
Weights  bias 
)
pure virtual

Add an layerCount deep RNN layer to the network with a sequence length of maxSeqLen and hiddenSize internal state per layer.

Parameters
inputsThe input tensor to the layer.
layerCountThe number of layers in the RNN.
hiddenSizeThe size of the internal hidden state for each layer.
maxSeqLenThe maximum length of the time sequence.
opThe type of RNN to execute.
modeThe input mode for the RNN.
dirThe direction to run the RNN.
weightsThe weights for the weight matrix parameters of the RNN.
biasThe 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.
See Also
IRNNLayer
Returns
The new RNN layer, or nullptr if it could not be created.
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
inputThe input tensor to the layer (see below).
layerCountThe number of layers in the RNN.
hiddenSizeSize of the internal hidden state for each layer.
maxSeqLenMaximum sequence length for the input.
opThe 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() if getDirection is kUNIDIRECTION, and 2x 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.
  • H is the hidden state for each layer, equal to getHiddenSize().
See Also
IRNNv2Layer
Returns
The new RNN layer, or nullptr if it could not be created.
virtual IScaleLayer* nvinfer1::INetworkDefinition::addScale ( ITensor input,
ScaleMode  mode,
Weights  shift,
Weights  scale,
Weights  power 
)
pure virtual

Add a Scale layer to the network.

Parameters
inputThe input tensor to The layer. This tensor is required to have a minimum of 3 dimensions.
modeThe scaling mode.
shiftThe shift value.
scaleThe scale value.
powerThe power value.

If the weights are available, then the size of weights are dependent on the on the ScaleMode. For kUNIFORM, the number of weights is equal to 1. For kCHANNEL, the number of weights is equal to the channel dimension. For kELEMENTWISE, the number of weights is equal to the volume of the input.

See Also
IScaleLayer
Returns
The new Scale layer, or nullptr if it could not be created.
virtual IShuffleLayer* nvinfer1::INetworkDefinition::addShuffle ( ITensor input)
pure virtual

Add a shuffle layer to the network.

Parameters
inputThe input tensor to the layer.
See Also
IShuffleLayer
Returns
The new shuffle layer, or nullptr if it could not be created.
virtual ISliceLayer* nvinfer1::INetworkDefinition::addSlice ( ITensor input,
Dims  start,
Dims  size,
Dims  stride 
)
pure virtual

Add a slice layer to the network.

Parameters
inputThe input tensor to the layer.
startThe start offset
sizeThe output dimension
strideThe slicing stride

Positive, negative, zero stride values, and combinations of them in different dimensions are allowed.

See Also
ISliceLayer
Returns
The new slice layer, or nullptr if it could not be created.
virtual ISoftMaxLayer* nvinfer1::INetworkDefinition::addSoftMax ( ITensor input)
pure virtual

Add a SoftMax layer to the network.

See Also
ISoftMaxLayer
Returns
The new SoftMax layer, or nullptr if it could not be created.
virtual ITopKLayer* nvinfer1::INetworkDefinition::addTopK ( ITensor input,
TopKOperation  op,
int  k,
uint32_t  reduceAxes 
)
pure virtual

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 1024 are supported.

Parameters
inputThe input tensor to the layer.
opOperation to perform.
kNumber of elements to keep.
reduceAxesThe reduction dimensions. Bit 0 of the uint32_t type corresponds to the non-batch dimension 0 boolean and so on. If a bit is set, then the corresponding dimension will be reduced. Let's say we have an NCHW tensor as input (three non-batch dimensions). Bit 0 corresponds to the C dimension boolean. Bit 1 corresponds to the H dimension boolean. Bit 2 corresponds to the W dimension boolean. Note that TopK reduction is currently only permitted over one dimension.
See Also
ITopKLayer
Returns
The new TopK layer, or nullptr if it could not be created.
virtual IUnaryLayer* nvinfer1::INetworkDefinition::addUnary ( ITensor input,
UnaryOperation  operation 
)
pure virtual

Add a unary layer to the network.

Parameters
inputThe input tensor to the layer.
operationThe operation to apply.
See Also
IUnaryLayer
Returns
The new unary layer, or nullptr if it could not be created
virtual IOutputDimensionsFormula& nvinfer1::INetworkDefinition::getConvolutionOutputDimensionsFormula ( ) const
pure virtual

Get the convolution output dimensions formula.

Deprecated:
This method does not currently work reliably and will be removed in a future release.
Returns
The formula from computing the convolution output dimensions.
See Also
IOutputDimensionsFormula setConvolutionOutputDimensionsFormula()
virtual IOutputDimensionsFormula& nvinfer1::INetworkDefinition::getDeconvolutionOutputDimensionsFormula ( ) const
pure virtual

Get the deconvolution output dimensions formula.

Returns
The formula from computing the deconvolution output dimensions.
Deprecated:
This method does not currently work reliably and will be removed in a future release.
See Also
IOutputDimensionsFormula setDeconvolutionOutputDimensionsFormula()
virtual ITensor* nvinfer1::INetworkDefinition::getInput ( int  index) const
pure virtual

Get the input tensor specified by the given index.

Parameters
indexThe index of the input tensor.
Returns
The input tensor, or nullptr if the index is out of range.
See Also
getNbInputs()
virtual ILayer* nvinfer1::INetworkDefinition::getLayer ( int  index) const
pure virtual

Get the layer specified by the given index.

Parameters
indexThe index of the layer.
Returns
The layer, or nullptr if the index is out of range.
See Also
getNbLayers()
virtual int nvinfer1::INetworkDefinition::getNbInputs ( ) const
pure virtual

Get the number of inputs in the network.

Returns
The number of inputs in the network.
See Also
getInput()
virtual int nvinfer1::INetworkDefinition::getNbLayers ( ) const
pure virtual

Get the number of layers in the network.

Returns
The number of layers in the network.
See Also
getLayer()
virtual int nvinfer1::INetworkDefinition::getNbOutputs ( ) const
pure virtual

Get the number of outputs in the network.

Returns
The number of outputs in the network.
See Also
getOutput()
virtual ITensor* nvinfer1::INetworkDefinition::getOutput ( int  index) const
pure virtual

Get the output tensor specified by the given index.

Parameters
indexThe index of the output tensor.
Returns
The output tensor, or nullptr if the index is out of range.
See Also
getNbOutputs()
virtual IOutputDimensionsFormula& nvinfer1::INetworkDefinition::getPoolingOutputDimensionsFormula ( ) const
pure virtual

Get the pooling output dimensions formula.

Returns
The formula from computing the pooling output dimensions.
See Also
IOutputDimensionsFormula setPoolingOutputDimensionsFormula()
virtual void nvinfer1::INetworkDefinition::markOutput ( ITensor tensor)
pure virtual

Mark a tensor as a network output.

Parameters
tensorThe tensor to mark as an output tensor.
virtual void nvinfer1::INetworkDefinition::removeTensor ( ITensor tensor)
pure virtual

remove a tensor from the network definition.

Parameters
tensorthe 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().

virtual void nvinfer1::INetworkDefinition::setConvolutionOutputDimensionsFormula ( IOutputDimensionsFormula formula)
pure virtual

Set the convolution output dimensions formula.

Deprecated:
This method does not currently work reliably and will be removed in a future release.
Parameters
formulaThe formula from computing the convolution output dimensions. If null is passed, the default formula is used.

The default formula in each dimension is (inputDim + padding * 2 - kernelSize) / stride + 1.

See Also
IOutputDimensionsFormula getConvolutionOutputDimensionsFormula()
virtual void nvinfer1::INetworkDefinition::setDeconvolutionOutputDimensionsFormula ( IOutputDimensionsFormula formula)
pure virtual

Set the deconvolution output dimensions formula.

Deprecated:
This method does not currently work reliably and will be removed in a future release.
Parameters
formulaThe formula from computing the deconvolution output dimensions. If null is passed, the default formula is used.

The default formula in each dimension is (inputDim - 1) * stride + kernelSize - 2 * padding.

See Also
IOutputDimensionsFormula getDevonvolutionOutputDimensionsFormula()
virtual void nvinfer1::INetworkDefinition::setPoolingOutputDimensionsFormula ( IOutputDimensionsFormula formula)
pure virtual

Set the pooling output dimensions formula.

Parameters
formulaThe formula from computing the pooling output dimensions. If null is passed, the default formula is used.

The default formula in each dimension is (inputDim + padding * 2 - kernelSize) / stride + 1.

See Also
IOutputDimensionsFormula getPoolingOutputDimensionsFormula()
virtual void nvinfer1::INetworkDefinition::unmarkOutput ( ITensor tensor)
pure virtual

unmark a tensor as a network output.

Parameters
tensorThe tensor to unmark as an output tensor.

see markOutput()


The documentation for this class was generated from the following file: