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
impl ILayer
Sourcepub unsafe fn setName(self: Pin<&mut ILayer>, name: *const c_char)
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()]
Sourcepub fn getNbInputs(self: &ILayer) -> i32
pub fn getNbInputs(self: &ILayer) -> i32
Get the number of inputs of a layer.
Sourcepub fn getInput(self: &ILayer, index: i32) -> *mut ITensor
pub fn getInput(self: &ILayer, index: i32) -> *mut ITensor
Get the layer input corresponding to the given index.
indexThe index of the input tensor.
The input tensor, or nullptr if the index is out of range or the tensor is optional ( ISliceLayer).
Sourcepub fn getNbOutputs(self: &ILayer) -> i32
pub fn getNbOutputs(self: &ILayer) -> i32
Get the number of outputs of a layer.
Sourcepub fn getOutput(self: &ILayer, index: i32) -> *mut ITensor
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.
Sourcepub fn setInput(self: Pin<&mut ILayer>, index: i32, tensor: Pin<&mut ITensor>)
pub fn setInput(self: Pin<&mut ILayer>, index: i32, tensor: Pin<&mut ITensor>)
Replace an input of this layer with a specific tensor.
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.
Sourcepub fn getOutputType(self: &ILayer, index: i32) -> DataType
pub fn getOutputType(self: &ILayer, index: i32) -> DataType
get the output type of this layer
indexthe index of the output
the inferred output type.
See [getOutputType()] outputTypeIsSet() resetOutputType()
Sourcepub unsafe fn setMetadata(self: Pin<&mut ILayer>, metadata: *const c_char)
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.
metadataThe per-layer metadata.
The string name must be null-terminated and be at most 4096 bytes including the terminator.
See [getMetadata()]
See [getLayerInformation()]
Sourcepub fn getMetadata(self: &ILayer) -> *const c_char
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()]
Sourcepub fn setNbRanks(self: Pin<&mut ILayer>, nbRanks: i32) -> bool
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.
nbRanksThe 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()
Sourcepub fn getNbRanks(self: &ILayer) -> i32
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()]