TensorRT 11.0.0
nvinfer1::ILayer Class Referenceabstract

Base class for all layer classes in a network definition. More...

#include <NvInfer.h>

Inheritance diagram for nvinfer1::ILayer:
nvinfer1::INoCopy nvinfer1::IActivationLayer nvinfer1::IAssertionLayer nvinfer1::IAttentionBoundaryLayer nvinfer1::ICastLayer nvinfer1::IConcatenationLayer nvinfer1::IConstantLayer nvinfer1::IConvolutionLayer nvinfer1::ICumulativeLayer nvinfer1::IDeconvolutionLayer nvinfer1::IDequantizeLayer nvinfer1::IDistCollectiveLayer nvinfer1::IDynamicQuantizeLayer nvinfer1::IEinsumLayer nvinfer1::IElementWiseLayer nvinfer1::IFillLayer nvinfer1::IGatherLayer nvinfer1::IGridSampleLayer nvinfer1::IIdentityLayer nvinfer1::IIfConditionalBoundaryLayer nvinfer1::IKVCacheUpdateLayer nvinfer1::ILRNLayer nvinfer1::ILoopBoundaryLayer nvinfer1::IMatrixMultiplyLayer nvinfer1::IMoELayer nvinfer1::INMSLayer nvinfer1::INonZeroLayer nvinfer1::INormalizationLayer nvinfer1::IOneHotLayer nvinfer1::IPaddingLayer nvinfer1::IParametricReLULayer nvinfer1::IPluginV2Layer nvinfer1::IPluginV3Layer nvinfer1::IPoolingLayer nvinfer1::IQuantizeLayer nvinfer1::IRaggedSoftMaxLayer nvinfer1::IReduceLayer nvinfer1::IResizeLayer nvinfer1::IReverseSequenceLayer nvinfer1::IRotaryEmbeddingLayer nvinfer1::IScaleLayer nvinfer1::IScatterLayer nvinfer1::ISelectLayer nvinfer1::IShapeLayer nvinfer1::IShuffleLayer nvinfer1::ISliceLayer nvinfer1::ISoftMaxLayer nvinfer1::ISqueezeLayer nvinfer1::ITopKLayer nvinfer1::IUnaryLayer nvinfer1::IUnsqueezeLayer

Public Member Functions

LayerType getType () const noexcept
 Return the type of a layer. More...
 
void setName (char const *name) noexcept
 Set the name of a layer. More...
 
char const * getName () const noexcept
 Return the name of a layer. More...
 
int32_t getNbInputs () const noexcept
 Get the number of inputs of a layer. More...
 
ITensorgetInput (int32_t index) const noexcept
 Get the layer input corresponding to the given index. More...
 
int32_t getNbOutputs () const noexcept
 Get the number of outputs of a layer. More...
 
ITensorgetOutput (int32_t index) const noexcept
 Get the layer output corresponding to the given index. More...
 
void setInput (int32_t index, ITensor &tensor) noexcept
 Replace an input of this layer with a specific tensor. More...
 
DataType getOutputType (int32_t index) const noexcept
 get the output type of this layer More...
 
void setMetadata (char const *metadata) noexcept
 Set the metadata for this layer. More...
 
char const * getMetadata () const noexcept
 Get the metadata of the layer. More...
 
bool setNbRanks (int32_t nbRanks) noexcept
 Set the number of ranks for multi-device execution. More...
 
int32_t getNbRanks () const noexcept
 Get the number of ranks for multi-device execution. More...
 

Protected Member Functions

virtual ~ILayer () noexcept=0
 
- Protected Member Functions inherited from nvinfer1::INoCopy
 INoCopy ()=default
 
virtual ~INoCopy ()=default
 
 INoCopy (INoCopy const &other)=delete
 
INoCopyoperator= (INoCopy const &other)=delete
 
 INoCopy (INoCopy &&other)=delete
 
INoCopyoperator= (INoCopy &&other)=delete
 

Protected Attributes

apiv::VLayer * mLayer
 

Detailed Description

Base class for all layer classes in a network definition.

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

Constructor & Destructor Documentation

◆ ~ILayer()

nvinfer1::ILayer::~ILayer ( )
inlineprotectedpure virtualdefaultnoexcept

Member Function Documentation

◆ getInput()

ITensor * nvinfer1::ILayer::getInput ( int32_t  index) const
inlinenoexcept

Get the layer input corresponding to the given index.

Parameters
indexThe index of the input tensor.
Returns
The input tensor, or nullptr if the index is out of range or the tensor is optional (ISliceLayer).

◆ getMetadata()

char const * nvinfer1::ILayer::getMetadata ( ) const
inlinenoexcept

Get the metadata of the layer.

Returns
The metadata as a null-terminated C-style string. If setMetadata() has not been called, an empty string "" will be returned as a default value.
See also
setMetadata()

◆ getName()

char const * nvinfer1::ILayer::getName ( ) const
inlinenoexcept

Return the name of a layer.

See also
setName()

◆ getNbInputs()

int32_t nvinfer1::ILayer::getNbInputs ( ) const
inlinenoexcept

Get the number of inputs of a layer.

◆ getNbOutputs()

int32_t nvinfer1::ILayer::getNbOutputs ( ) const
inlinenoexcept

Get the number of outputs of a layer.

◆ getNbRanks()

int32_t nvinfer1::ILayer::getNbRanks ( ) const
inlinenoexcept

Get the number of ranks for multi-device execution.

Returns
The number of ranks configured for multi-device execution. Default is 1.
See also
setNbRanks()

◆ getOutput()

ITensor * nvinfer1::ILayer::getOutput ( int32_t  index) const
inlinenoexcept

Get the layer output corresponding to the given index.

Returns
The indexed output tensor, or nullptr if the index is out of range or the tensor is optional.

◆ getOutputType()

DataType nvinfer1::ILayer::getOutputType ( int32_t  index) const
inlinenoexcept

get the output type of this layer

Parameters
indexthe index of the output
Returns
the inferred output type.
See also
getOutputType() outputTypeIsSet() resetOutputType()

◆ getType()

LayerType nvinfer1::ILayer::getType ( ) const
inlinenoexcept

Return the type of a layer.

See also
LayerType

◆ setInput()

void nvinfer1::ILayer::setInput ( int32_t  index,
ITensor tensor 
)
inlinenoexcept

Replace an input of this layer with a specific tensor.

Parameters
indexthe index of the input to modify.
tensorthe new input tensor

Except for IFillLayer, ILoopOutputLayer, INMSLayer, IResizeLayer, IShuffleLayer, and ISliceLayer, this method cannot change the number of inputs to a layer. The index argument must be less than the value of getNbInputs().

See comments for overloads of setInput() for layers with special behavior.

◆ setMetadata()

void nvinfer1::ILayer::setMetadata ( char const *  metadata)
inlinenoexcept

Set the metadata for this layer.

The metadata is emitted in the JSON returned by IEngineInspector with ProfilingVerbosity set to kDETAILED.

Parameters
metadataThe per-layer metadata.
Warning
The string name must be null-terminated and be at most 4096 bytes including the terminator.
See also
getMetadata()
getLayerInformation()

◆ setName()

void nvinfer1::ILayer::setName ( char const *  name)
inlinenoexcept

Set the name of a layer.

This method copies the name string.

Warning
The string name must be null-terminated, and be at most 4096 bytes including the terminator.
See also
getName()

◆ setNbRanks()

bool nvinfer1::ILayer::setNbRanks ( int32_t  nbRanks)
inlinenoexcept

Set the number of ranks for multi-device execution.

Setting nbRanks > 1 is only allowed for specific layer types that support multi-device execution:

For attention layers, use IAttention::setNbRanks() instead. For all other layer types, nbRanks must be 1.

Parameters
nbRanksThe number of ranks for multi-device execution. Must be >= 1.
Returns
true if successful, false if the layer type does not support the specified nbRanks value.
See also
getNbRanks()
IAttention::setNbRanks()

Member Data Documentation

◆ mLayer

apiv::VLayer* nvinfer1::ILayer::mLayer
protected

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

  Copyright © 2024 NVIDIA Corporation
  Privacy Policy | Manage My Privacy | Do Not Sell or Share My Data | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact