Skip to main content

ILayer

Struct ILayer 

Source
pub struct ILayer { /* private fields */ }
Expand description

ILayer

Base class for all layer classes in a network definition.

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

Implementations§

Source§

impl ILayer

Source

pub fn getType(self: &ILayer) -> LayerType

Return the type of a layer.

See LayerType

Source

pub unsafe fn setName(self: Pin<&mut ILayer>, name: *const c_char)

Set the name of a layer.

This method copies the name string.

The string name must be null-terminated, and be at most 4096 bytes including the terminator.

See [getName()]

Source

pub fn getName(self: &ILayer) -> *const c_char

Return the name of a layer.

See [setName()]

Source

pub fn getNbInputs(self: &ILayer) -> i32

Get the number of inputs of a layer.

Source

pub fn getInput(self: &ILayer, index: i32) -> *mut ITensor

Get the layer input corresponding to the given index.

  • index The index of the input tensor.

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

Source

pub fn getNbOutputs(self: &ILayer) -> i32

Get the number of outputs of a layer.

Source

pub fn getOutput(self: &ILayer, index: i32) -> *mut ITensor

Get the layer output corresponding to the given index.

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

Source

pub fn setInput(self: Pin<&mut ILayer>, index: i32, tensor: Pin<&mut ITensor>)

Replace an input of this layer with a specific tensor.

  • index the index of the input to modify.
  • tensor the 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.

Source

pub fn setPrecision(self: Pin<&mut ILayer>, dataType: DataType)

Set the preferred or required computational precision of this layer in a weakly-typed network.

Setting the precision directs TensorRT to choose an implementation that runs at this computational precision. TensorRT could still choose a non-conforming fastest implementation that ignores the requested precision. To force choosing an implementation with the requested precision, set exactly one of the following flags, which differ in what happens if no such implementation exists:

  • BuilderFlag::kOBEY_PRECISION_CONSTRAINTS - build fails with an error message.

  • BuilderFlag::kPREFER_PRECISION_CONSTRAINTS - TensorRT falls back to an implementation without the requested precision.

If precision is not set, or falling back, TensorRT will select the layer computational precision and layer input type based on global performance considerations and the flags specified to the builder.

For a IIdentityLayer: If it casts to/from float/half/int8/uint8, the precision must be one of those types, otherwise it must be either the input or output type.

Strongly-typed networks reject calls to method setPrecision. In strongly-typed networks, the computation precision is typically controlled by casting the input tensors to the desired type.

  • dataType the computational precision.

See [getPrecision()] precisionIsSet() resetPrecision()

Unsupported in TensorRT-RTX and deprecated in 1.0. Use strong typing instead.

Source

pub fn getPrecision(self: &ILayer) -> DataType

get the computational precision of this layer

the computational precision

See [setPrecision()] precisionIsSet() resetPrecision()

Source

pub fn precisionIsSet(self: &ILayer) -> bool

whether the computational precision has been set for this layer

whether the computational precision has been explicitly set

See [setPrecision()] getPrecision() resetPrecision()

Unsupported in TensorRT-RTX and deprecated in 1.0. Use strong typing instead.

Source

pub fn resetPrecision(self: Pin<&mut ILayer>)

reset the computational precision for this layer

See [setPrecision()] getPrecision() precisionIsSet()

Unsupported in TensorRT-RTX and deprecated in 1.0. Use strong typing instead.

Source

pub fn setOutputType(self: Pin<&mut ILayer>, index: i32, dataType: DataType)

Set the output type of this layer in a weakly-typed network.

Setting the output type constrains TensorRT to choose implementations which generate output data with the given type. If it is not set, TensorRT will select output type based on layer computational precision. TensorRT could still choose non-conforming output type based on fastest implementation. To force choosing the requested output type, set exactly one of the following flags, which differ in what happens if no such implementation exists:

  • BuilderFlag::kOBEY_PRECISION_CONSTRAINTS - build fails with an error message.

  • BuilderFlag::kPREFER_PRECISION_CONSTRAINTS - TensorRT falls back to an implementation with a non-conforming output type.

In case layer precision is not specified, or falling back, the output type depends on the chosen implementation, based on performance considerations and the flags specified to the builder.

This method cannot be used to set the data type of the second output tensor of the TopK layer. The data type of the second output tensor of the topK layer is always Int32. Also the output type of all layers that are shape operations must be DataType::kINT32, and all attempts to set the output type to some other data type will be ignored except for issuing an error message.

Note that the layer output type is generally not identical to the data type of the output tensor, as TensorRT may insert implicit reformatting operations to convert the former to the latter. Calling layer->setOutputType(i, type) has no effect on the data type of the i-th output tensor of layer, and users need to call layer->getOutput(i)->setType(type) to change the tensor data type. This is particularly relevant if the tensor is marked as a network output, since only setType() [but not setOutputType()] will affect the data representation in the corresponding output binding.

Strongly-typed networks reject calls to method setOutputType. Instead, the output type can be set only for layers that define method setToType(). Those layers are:

  • ICastLayer
  • IDequantizeLayer
  • IDynamicQuantizeLayer
  • IFillLayer
  • IQuantizeLayer
  • index the index of the output to set
  • dataType the type of the output

See [getOutputType()] outputTypeIsSet() resetOutputType()

Unsupported in TensorRT-RTX and deprecated in 1.0. Use strong typing instead.

Source

pub fn getOutputType(self: &ILayer, index: i32) -> DataType

get the output type of this layer

  • index the index of the output

the output precision. If no precision has been set, DataType::kFLOAT will be returned, unless the output type is inherently DataType::kINT32.

See [getOutputType()] outputTypeIsSet() resetOutputType()

Source

pub fn outputTypeIsSet(self: &ILayer, index: i32) -> bool

whether the output type has been set for this layer

  • index the index of the output

whether the output type has been explicitly set

See [setOutputType()] getOutputType() resetOutputType()

Unsupported in TensorRT-RTX and deprecated in 1.0. Use strong typing instead.

Source

pub fn resetOutputType(self: Pin<&mut ILayer>, index: i32)

reset the output type for this layer

  • index the index of the output

See [setOutputType()] getOutputType() outputTypeIsSet()

Unsupported in TensorRT-RTX and deprecated in 1.0. Use strong typing instead.

Source

pub unsafe fn setMetadata(self: Pin<&mut ILayer>, metadata: *const c_char)

Set the metadata for this layer.

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

  • metadata The per-layer metadata.

The string name must be null-terminated and be at most 4096 bytes including the terminator.

See [getMetadata()] See [getLayerInformation()]

Source

pub fn getMetadata(self: &ILayer) -> *const c_char

Get the metadata of the layer.

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 [setMetadata()]

Source

pub fn setNbRanks(self: Pin<&mut ILayer>, nbRanks: i32) -> bool

Set the number of ranks for multi-device execution.

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

  • IDistCollectiveLayer: Determines output shape for kALL_GATHER and kREDUCE_SCATTER operations.

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

  • nbRanks The number of ranks for multi-device execution. Must be >= 1.

true if successful, false if the layer type does not support the specified nbRanks value.

See [getNbRanks()] See IAttention::setNbRanks()

Source

pub fn getNbRanks(self: &ILayer) -> i32

Get the number of ranks for multi-device execution.

The number of ranks configured for multi-device execution. Default is 1.

See [setNbRanks()]

Trait Implementations§

Source§

impl AsLayer for ILayer

Source§

fn as_layer(&self) -> &ILayer

Source§

fn as_layer_pin_mut(&mut self) -> Pin<&mut ILayer>

Source§

impl AsRef<ILayer> for IActivationLayer

Source§

fn as_ref(self: &IActivationLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IAssertionLayer

Source§

fn as_ref(self: &IAssertionLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IAttentionBoundaryLayer

Source§

fn as_ref(self: &IAttentionBoundaryLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for ICastLayer

Source§

fn as_ref(self: &ICastLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IConcatenationLayer

Source§

fn as_ref(self: &IConcatenationLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IConstantLayer

Source§

fn as_ref(self: &IConstantLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IConvolutionLayer

Source§

fn as_ref(self: &IConvolutionLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for ICumulativeLayer

Source§

fn as_ref(self: &ICumulativeLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IDeconvolutionLayer

Source§

fn as_ref(self: &IDeconvolutionLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IDequantizeLayer

Source§

fn as_ref(self: &IDequantizeLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IDistCollectiveLayer

Source§

fn as_ref(self: &IDistCollectiveLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IDynamicQuantizeLayer

Source§

fn as_ref(self: &IDynamicQuantizeLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IEinsumLayer

Source§

fn as_ref(self: &IEinsumLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IElementWiseLayer

Source§

fn as_ref(self: &IElementWiseLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IFillLayer

Source§

fn as_ref(self: &IFillLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IGatherLayer

Source§

fn as_ref(self: &IGatherLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IGridSampleLayer

Source§

fn as_ref(self: &IGridSampleLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IIdentityLayer

Source§

fn as_ref(self: &IIdentityLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IKVCacheUpdateLayer

Source§

fn as_ref(self: &IKVCacheUpdateLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for ILRNLayer

Source§

fn as_ref(self: &ILRNLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for ILoopBoundaryLayer

Source§

fn as_ref(self: &ILoopBoundaryLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IMatrixMultiplyLayer

Source§

fn as_ref(self: &IMatrixMultiplyLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IMoELayer

Source§

fn as_ref(self: &IMoELayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for INMSLayer

Source§

fn as_ref(self: &INMSLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for INonZeroLayer

Source§

fn as_ref(self: &INonZeroLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for INormalizationLayer

Source§

fn as_ref(self: &INormalizationLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IOneHotLayer

Source§

fn as_ref(self: &IOneHotLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IPaddingLayer

Source§

fn as_ref(self: &IPaddingLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IParametricReLULayer

Source§

fn as_ref(self: &IParametricReLULayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IPoolingLayer

Source§

fn as_ref(self: &IPoolingLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IQuantizeLayer

Source§

fn as_ref(self: &IQuantizeLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IRaggedSoftMaxLayer

Source§

fn as_ref(self: &IRaggedSoftMaxLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IReduceLayer

Source§

fn as_ref(self: &IReduceLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IResizeLayer

Source§

fn as_ref(self: &IResizeLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IReverseSequenceLayer

Source§

fn as_ref(self: &IReverseSequenceLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IRotaryEmbeddingLayer

Source§

fn as_ref(self: &IRotaryEmbeddingLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IScaleLayer

Source§

fn as_ref(self: &IScaleLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IScatterLayer

Source§

fn as_ref(self: &IScatterLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for ISelectLayer

Source§

fn as_ref(self: &ISelectLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IShapeLayer

Source§

fn as_ref(self: &IShapeLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IShuffleLayer

Source§

fn as_ref(self: &IShuffleLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for ISliceLayer

Source§

fn as_ref(self: &ISliceLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for ISoftMaxLayer

Source§

fn as_ref(self: &ISoftMaxLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for ISqueezeLayer

Source§

fn as_ref(self: &ISqueezeLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for ITopKLayer

Source§

fn as_ref(self: &ITopKLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IUnaryLayer

Source§

fn as_ref(self: &IUnaryLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ILayer> for IUnsqueezeLayer

Source§

fn as_ref(self: &IUnsqueezeLayer) -> &ILayer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl ExternType for ILayer

Source§

type Id = (n, v, i, n, f, e, r, _1, (), I, L, a, y, e, r)

A type-level representation of the type’s C++ namespace and type name. Read more
Source§

type Kind = Opaque

Source§

impl MakeCppStorage for ILayer

Source§

unsafe fn allocate_uninitialized_cpp_storage() -> *mut ILayer

Allocates heap space for this type in C++ and return a pointer to that space, but do not initialize that space (i.e. do not yet call a constructor). Read more
Source§

unsafe fn free_uninitialized_cpp_storage(arg0: *mut ILayer)

Frees a C++ allocation which has not yet had a constructor called. Read more

Auto Trait Implementations§

§

impl !Freeze for ILayer

§

impl !RefUnwindSafe for ILayer

§

impl !Send for ILayer

§

impl !Sync for ILayer

§

impl Unpin for ILayer

§

impl UnsafeUnpin for ILayer

§

impl UnwindSafe for ILayer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.