NVIDIA NvNeural SDK  2022.2
GPU inference framework for NVIDIA Nsight Deep Learning Designer
nvneural::ILibraryContext Class Referenceabstract

ILibraryContext is a generic library handle wrapper. More...

#include <nvneural/CoreTypes.h>

Inheritance diagram for nvneural::ILibraryContext:
nvneural::IRefObject

Public Types

using LibraryId = std::uint64_t
 Library IDs should be generated randomly similar to interface IDs.
 
- 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.
 

Public Member Functions

virtual NeuralResult bindCurrentThread (INetworkBackend *pBackend) noexcept=0
 Thread rebinding callback. More...
 
virtual LibraryId libraryId () const noexcept=0
 Retrieves a stable identifier for the library being tracked in this object.
 
virtual NeuralResult synchronize (INetworkBackend *pBackend) noexcept=0
 Synchronization callback. 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 = 0x1ec1c40bfc1e45a4ul
 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

- 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

ILibraryContext is a generic library handle wrapper.

External libraries such as cuBLAS, cuSolver, or NPP are generally shareable across multiple layers and wasteful to instantiate on a per-layer basis. Not all layers require such libraries, however, and so including them directly in the backend-specific interfaces is undesirable.

We compromise by providing a key-value store in INetworkBackend; for more details, see INetworkBackend::getLibraryContext and related functions.

ILibraryContext objects have callback support, so that they can be notified when their owning network backend performs a CPU/GPU synchronization or rebinds to a new thread.

There is no default getHandle() method; clients should downcast to the appropriate leaf interface (e.g., ICublasLibraryContext) and use type-safe accessors.

Member Function Documentation

◆ bindCurrentThread()

virtual NeuralResult nvneural::ILibraryContext::bindCurrentThread ( INetworkBackend pBackend)
pure virtualnoexcept

Thread rebinding callback.

The implementation should rebind its library context to the current thread.

Parameters
pBackendOwning backend binding current thread

◆ synchronize()

virtual NeuralResult nvneural::ILibraryContext::synchronize ( INetworkBackend pBackend)
pure virtualnoexcept

Synchronization callback.

The implementation should perform a CPU/GPU sync if the library provides such an API.

Parameters
pBackendOwning backend performing synchronization

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