TensorRT
 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 Scale 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
 

Detailed Description

a network definition for input to the builder

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
See Also
IActivationLayer ActivationType
Returns
the new convolution layer, or null 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 null if it could not be created
Warning
All tensors must have the same dimensions for all dimensions except for channel.
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 null 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 null 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
See Also
IElementWiseLayer
Returns
the new elementwise layer, or null 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

the input to a fully connected layer is automatically flattened to a tensor of the form NxCx1x1, and the output is of the form NxKx1x1, where C is the nunber of input activations per image, and K is the number of outputs per image.

Returns
the new convolution layer, or null 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 and DataType::kHALF are valid input tensor types. The volume of the dimension, 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 null if it could not be created
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 null 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 null 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 null 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 layout for the input tensor is {1, T, N, C} and defined as follows:

  • T - The number of time sequences to be executed.
  • N - The number of mini-batches for each time sequence.
  • C - The size of data to be submitted to the RNN.

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.

The RNN layer outputs up to three tensors. The first tensor has dim {1, T, N, C}, is the output of the RNN for each timestep, and defined as follows:

  • T - The number of sequences to be executed.
  • N - The number of mini-batches for each time sequence.
  • C - The hidden state for each layer. Equal to getHiddenSize() if getDirection is RNNDirection::kUNIDIRECTION, and 2x getHiddenSize() otherwise.

The second tensor has dimension {1, L, N, H}, is the final hidden state of the RNN, and defined as follows.

  • L - The number of layers in the RNN, equal to getLayerCount()
  • N - The number of mini-batches for each time sequence.
  • H - The hidden state for each layer. Equal to getHiddenSize() if getDirection is RNNDirection::kUNIDIRECTION, and 2x getHiddenSize() otherwise.

The third tensor has dimension {1, L, N, H}, is the final cell state of the RNN, and defined as follows.

  • L - The number of layers in the RNN, equal to getLayerCount()
  • N - The number of mini-batches for each time sequence.
  • H - The hidden state for each layer. Equal to getHiddenSize() if getDirection is RNNDirection::kUNIDIRECTION, and 2x getHiddenSize() otherwise.

The third tensor is only available if getOperation() is RNNDirection::kLSTM.

Returns
the new RNN layer, or null if it could not be created.
See Also
IRNNLayer::setW(), IRNNLayer::setU(), IRNNLayer::setB()
IRNNLayer
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
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 ScaleMode::kUNIFORM, the number of weights is equal to 1. For ScaleMode::kCHANNEL, the number of weights is equal to the channel dimension. For ScaleMode::kELEMENTWISE, the number of weights is equal to the volume of the input.

See Also
IScaleLayer
Returns
the new Scale layer, or null 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
Returns
the new shuffle layer, or null if it could not be created
virtual ISoftMaxLayer* nvinfer1::INetworkDefinition::addSoftMax ( ITensor input)
pure virtual

add a Scale layer to the network

See Also
ISoftMaxLayer
Returns
the new SoftMax layer, or null 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 null 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 null 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 null 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 null 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::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()

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