NVIDIA NvNeural SDK  2022.1
GPU inference framework for NVIDIA Nsight Deep Learning Designer
nvneural::INetwork Class Referenceabstract

INetwork is the public interface to Network. More...

#include <nvneural/NetworkTypes.h>

Inheritance diagram for nvneural::INetwork:
nvneural::INetworkRuntime nvneural::IRefObject nvneural::INetwork2 nvneural::INetwork3

Public Member Functions

virtual NeuralResult attachNetworkDebugger (INetworkDebugger *pDebugger) noexcept=0
 Attaches a debugger object to the network. More...
 
virtual NeuralResult attachReshapeDebugger (INetworkReshapeDebugger *pDebugger) noexcept=0
 Attaches a reshape debugger object to the network. More...
 
virtual NeuralResult bindCurrentThread () noexcept=0
 Binds the network to the current thread. More...
 
virtual NeuralResult clearLayers () noexcept=0
 Releases all layers from the network.
 
virtual NeuralResult clearLoadedWeights () noexcept=0
 Clears the cache of loaded weights. More...
 
virtual NeuralResult copyTensor (const ILayer *pSourceLayer, ILayer *pDestinationLayer) noexcept=0
 Copy the output tensor from one layer to another.
 
virtual IActivationFunctiondefaultForwardActivationFunction (const ILayer *pLayer) const noexcept=0
 Retrieves the activation function consumed by defaultForwardActivation. More...
 
virtual NeuralResult detachAllNetworkDebuggers () noexcept=0
 Detaches all debuggers from the network.
 
virtual NeuralResult detachAllReshapeDebuggers () noexcept=0
 Detaches all reshape debuggers from the network.
 
virtual NeuralResult detachNetworkDebugger (const INetworkDebugger *pDebugger) noexcept=0
 Detaches a debugger object from the network.
 
virtual NeuralResult detachReshapeDebugger (const INetworkReshapeDebugger *pDebugger) noexcept=0
 Detaches a debugger object from the network.
 
virtual const IClassRegistrygetClassRegistry () const noexcept=0
 Get the IClassRegistry used by the network.
 
virtual NeuralResult getNetworkDebuggers (INetworkDebuggerList **ppListOut) const noexcept=0
 Retrieves the list of attached network debuggers. More...
 
virtual NeuralResult getProcessedLayerInputList (const ILayer *pLayer, ILayerList **ppProcessedInputLayerList) const noexcept=0
 Get a layer input list and preprocess it to replace any inner NetworkLayer's layer by the NetworkLayer itself. More...
 
virtual NeuralResult getWeightsNamesForLayer (IStringList **ppListOut, const ILayer *pLayer) const noexcept=0
 Retrieves a list of weights consumed by a layer. More...
 
virtual NeuralResult setClassRegistry (const IClassRegistry *pRegistry) noexcept=0
 Set an IClassRegistry object to this network. More...
 
virtual NeuralResult synchronize () noexcept=0
 Performs a CPU/GPU sync and completes pending operations.
 
virtual NeuralResult unload () noexcept=0
 Releases member data and theoretically breaks cycles between Networks/Layers not using weak references. More...
 
Initialization functions
virtual NeuralResult attachBackend (INetworkBackend *pBackend) noexcept=0
 Attaches a backend to the network. More...
 
virtual NeuralResult setDefaultBackendId (NetworkBackendId backendId) noexcept=0
 Sets the default backend for the network. More...
 
virtual NeuralResult setDefaultTensorFormat (const TensorFormat &tensorFormat) noexcept=0
 Sets the default tensor format for the network.
 
virtual NeuralResult setNetworkName (const char *pName) noexcept=0
 Sets the name for the network. More...
 
virtual NeuralResult setOptimizationFlag (NetworkBackendId backendId, INetworkBackend::OptimizationCapability capability, bool enabled) noexcept=0
 Sets if the indicated optimization is applicable to the passed backend.
 
virtual bool isOptimizationFlagEnabled (NetworkBackendId backendId, INetworkBackend::OptimizationCapability capability) const noexcept=0
 Gets if the indicated optimization is enabled to the passed backend.
 
virtual NeuralResult setWeightsLoader (IWeightsLoader *pWeightsLoader) noexcept=0
 Sets the weights loader for the network. More...
 
virtual NeuralResult pushLayer (ILayer *pLayer) noexcept=0
 Adds a layer to the network. More...
 
virtual NeuralResult pushLayerAlias (const char *pAliasName, ILayer *pLayer) noexcept=0
 Adds an alias for a layer. More...
 
Reshape functions
virtual NeuralResult reshapeAll () noexcept=0
 Reshapes the entire network.
 
virtual NeuralResult reshape (ILayerList *pMarkedLayers) noexcept=0
 Reshapes a subgraph. More...
 
Inference
virtual NeuralResult inferenceSubgraph (ILayerList *pInputs, ILayerList *pOutputs) noexcept=0
 Performs inference across a subgraph. More...
 
virtual NeuralResult inference () noexcept=0
 Performs inference on the network. More...
 
- Public Member Functions inherited from nvneural::INetworkRuntime
virtual NetworkBackendId defaultBackendId () const noexcept=0
 Retrieves the default backend ID used by the network.
 
virtual NeuralResult defaultForwardActivation (ILayer *pLayer) const noexcept=0
 Perform generic forward activation. More...
 
virtual TensorFormat defaultTensorFormat () const noexcept=0
 Retrieves the default tensor format used by the network.
 
virtual const INetworkBackendgetBackend (NetworkBackendId backendId) const noexcept=0
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
virtual INetworkBackendgetBackend (NetworkBackendId backendId) noexcept=0
 Retrieves an installed network backend. More...
 
virtual void * getInternalTensor (const ILayer *pLayer, NetworkBackendId backendId) noexcept=0
 Retrieves internal tensor data for a layer. More...
 
virtual TensorDimension getLayerInternalDimensions (const ILayer *pLayer) const noexcept=0
 Retrieves the internal dimensions of a layer. More...
 
virtual void * getTensor (const ILayer *pDataLayer, const ILayer *pRequestingLayer, TensorFormat format) noexcept=0
 Retrieves tensor data from one layer on behalf of another. More...
 
virtual NeuralResult getWeightsDimensionForLayer (TensorDimension *pDimensionsOut, const ILayer *pLayer, const char *pWeightsName, NetworkBackendId backendId, TensorFormat format) noexcept=0
 Retrieves the dimensions of specific weights data for a layer. More...
 
virtual const void * getWeightsForLayer (const ILayer *pLayer, const char *pWeightsName, NetworkBackendId backendId, TensorFormat format) noexcept=0
 Retrieves specific weights data for a layer. More...
 
virtual NeuralResult mapLayerAsWeightsData (const ILayer *pDataLayer, const ILayer *pWeightsLayer, const char *pWeightsName) noexcept=0
 Maps a layer as a source of weights data for another layer. More...
 
virtual const char * networkName () const noexcept=0
 Retrieves the name of this network as a UTF-8 string.
 
virtual NeuralResult reshapeLater (ILayer *pLayer) noexcept=0
 Queues a layer for later reshape. More...
 
virtual NeuralResult setAffectedForward (ILayer *pLayer) noexcept=0
 Marks a layer and its descendants (those layers indirectly depending on it) as "affected.". More...
 
virtual IWeightsLoaderweightsLoader () const noexcept=0
 Retrieves the IWeightsLoader implementation for this network.
 
virtual size_t layerCount () const noexcept=0
 Gets the current number of layers in the network.
 
virtual ILayergetLayerByName (const char *pLayerName) const noexcept=0
 Retrieves a layer by name. More...
 
virtual NeuralResult getAllLayers (ILayerList **ppListOut) const noexcept=0
 Retrieves a list of layers present in the network. More...
 
virtual NeuralResult getInputLayers (ILayerList **ppListOut) const noexcept=0
 Retrieves a list of input layers present in the network. More...
 
virtual NeuralResult getOutputLayers (ILayerList **ppListOut) const noexcept=0
 Retrieves a list of output layers present in the network. More...
 
virtual NeuralResult getDependentLayers (ILayerList **ppListOut, const ILayer *pLayer) const noexcept=0
 Retrieves a list of layers indirectly depending on pLayer. More...
 
virtual NeuralResult getAcceptorLayers (ILayerList **ppListOut, const ILayer *pLayer) const noexcept=0
 Retrieves a list of layers directly depending on pLayer. More...
 
virtual NeuralResult getInfluenceLayers (ILayerList **ppListOut, const ILayer *pLayer) const noexcept=0
 Retrieves a list of layers pLayer indirectly depends on. More...
 
- Public Member Functions inherited from nvneural::IRefObject
virtual RefCount addRef () const noexcept=0
 Increments the object's reference count. More...
 
virtual const void * queryInterface (TypeId interface) const noexcept=0
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
virtual void * queryInterface (TypeId interface) noexcept=0
 Retrieves a new object interface pointer. More...
 
virtual RefCount release () const noexcept=0
 Decrements the object's reference count and destroy the object if the reference count reaches zero. More...
 

Static Public Attributes

static const IRefObject::TypeId typeID = 0x9ce8f71bf65288e9ul
 Interface TypeId for InterfaceOf purposes.
 
- Static Public Attributes inherited from nvneural::INetworkRuntime
static const IRefObject::TypeId typeID = 0x53191c073f990992ul
 Interface TypeId for InterfaceOf purposes.
 
- Static Public Attributes inherited from nvneural::IRefObject
static const TypeId typeID = 0x14ecc3f9de638e1dul
 Interface TypeId for InterfaceOf purposes.
 

Additional Inherited Members

- Public Types inherited from nvneural::IRefObject
using RefCount = std::uint32_t
 Typedef used to track the number of active references to an object.
 
using TypeId = std::uint64_t
 Every interface must define a unique TypeId. This should be randomized.
 
- Protected Member Functions inherited from nvneural::IRefObject
virtual ~IRefObject ()=default
 A protected destructor prevents accidental stack-allocation of IRefObjects or use with other smart pointer classes like std::unique_ptr.
 

Detailed Description

INetwork is the public interface to Network.

Member Function Documentation

◆ attachBackend()

virtual NeuralResult nvneural::INetwork::attachBackend ( INetworkBackend pBackend)
pure virtualnoexcept

Attaches a backend to the network.

The backend is assumed to be fully constructed (all device handles and contexts initialized, etc.).

The backend ID must be unique within this network.

◆ attachNetworkDebugger()

virtual NeuralResult nvneural::INetwork::attachNetworkDebugger ( INetworkDebugger pDebugger)
pure virtualnoexcept

Attaches a debugger object to the network.

The network takes a reference to the debugger.

◆ attachReshapeDebugger()

virtual NeuralResult nvneural::INetwork::attachReshapeDebugger ( INetworkReshapeDebugger pDebugger)
pure virtualnoexcept

Attaches a reshape debugger object to the network.

The network takes a reference to the debugger.

◆ bindCurrentThread()

virtual NeuralResult nvneural::INetwork::bindCurrentThread ( )
pure virtualnoexcept

Binds the network to the current thread.

Some backends or external libraries may have thread affinity. Calling this function rebinds them for access from the calling thread.

Warning
For obvious reasons, this function is not thread-safe. If your code requires concurrent non-const access to the network from multiple threads, consider redesigning. Failing that, add your own synchronization around thread access; lock a mutex, rebind to current thread, do work, and unlock the mutex.

◆ clearLoadedWeights()

virtual NeuralResult nvneural::INetwork::clearLoadedWeights ( )
pure virtualnoexcept

Clears the cache of loaded weights.

Must be done if you change weights loader behavior significantly; there is no notification hook for the weights loader to trigger this itself.

◆ defaultForwardActivationFunction()

virtual IActivationFunction* nvneural::INetwork::defaultForwardActivationFunction ( const ILayer pLayer) const
pure virtualnoexcept

Retrieves the activation function consumed by defaultForwardActivation.

Parameters
pLayerLayer to query
Returns
IActivationFunction that would be used for activation, or nullptr if layer has no activation or if no valid object exists. Does not increment reference count.

◆ getNetworkDebuggers()

virtual NeuralResult nvneural::INetwork::getNetworkDebuggers ( INetworkDebuggerList **  ppListOut) const
pure virtualnoexcept

Retrieves the list of attached network debuggers.

Parameters
ppListOutPointer receiving a reference to a new INetworkDebuggerList object.

◆ getProcessedLayerInputList()

virtual NeuralResult nvneural::INetwork::getProcessedLayerInputList ( const ILayer pLayer,
ILayerList **  ppProcessedInputLayerList 
) const
pure virtualnoexcept

Get a layer input list and preprocess it to replace any inner NetworkLayer's layer by the NetworkLayer itself.

Parameters
pLayerthe layer to retrive the input list from
ppProcessedInputLayerListlayer list containing the input of the layer

◆ getWeightsNamesForLayer()

virtual NeuralResult nvneural::INetwork::getWeightsNamesForLayer ( IStringList **  ppListOut,
const ILayer pLayer 
) const
pure virtualnoexcept

Retrieves a list of weights consumed by a layer.

The list is sorted alphabetically. If the layer does not consume weights, an empty list is returned.

Parameters
ppListOutVariable receiving a reference to a new IStringList. Caller must release the reference.
pLayerLayer to query

◆ inference()

virtual NeuralResult nvneural::INetwork::inference ( )
pure virtualnoexcept

Performs inference on the network.

Layers not marked "affected," or not connected to the output layers returned by getOutputLayers, will not be evaluated.

◆ inferenceSubgraph()

virtual NeuralResult nvneural::INetwork::inferenceSubgraph ( ILayerList pInputs,
ILayerList pOutputs 
)
pure virtualnoexcept

Performs inference across a subgraph.

Parameters
pInputsList of layers to perform inference from
pOutputsList of layers to target inference to

◆ pushLayer()

virtual NeuralResult nvneural::INetwork::pushLayer ( ILayer pLayer)
pure virtualnoexcept

Adds a layer to the network.

The layer is assumed to be fully constructed (all inputs hooked up, etc.).

◆ pushLayerAlias()

virtual NeuralResult nvneural::INetwork::pushLayerAlias ( const char *  pAliasName,
ILayer pLayer 
)
pure virtualnoexcept

Adds an alias for a layer.

The layer is assumed to be fully constructed (all inputs hooked up, etc.) and already added to the network.

◆ reshape()

virtual NeuralResult nvneural::INetwork::reshape ( ILayerList pMarkedLayers)
pure virtualnoexcept

Reshapes a subgraph.

The specified layers and all layers indirectly depending on them are reshaped.

Parameters
pMarkedLayersList of layers in the subgraph

◆ setClassRegistry()

virtual NeuralResult nvneural::INetwork::setClassRegistry ( const IClassRegistry pRegistry)
pure virtualnoexcept

Set an IClassRegistry object to this network.

Must be called before attaching network backends.

Parameters
pRegistryPointer to an IClassRegistry object

◆ setDefaultBackendId()

virtual NeuralResult nvneural::INetwork::setDefaultBackendId ( NetworkBackendId  backendId)
pure virtualnoexcept

Sets the default backend for the network.

The backend must already be known to the network (using attachBackend).

◆ setNetworkName()

virtual NeuralResult nvneural::INetwork::setNetworkName ( const char *  pName)
pure virtualnoexcept

Sets the name for the network.

Network names may not contain the '/' character.

Parameters
pNameNull-terminated UTF-8 string naming the network.

◆ setWeightsLoader()

virtual NeuralResult nvneural::INetwork::setWeightsLoader ( IWeightsLoader pWeightsLoader)
pure virtualnoexcept

Sets the weights loader for the network.

Parameters
pWeightsLoaderAn object implementing IWeightsLoader

◆ unload()

virtual NeuralResult nvneural::INetwork::unload ( )
pure virtualnoexcept

Releases member data and theoretically breaks cycles between Networks/Layers not using weak references.

Allows for safe destruction of the Network instance.


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