NVIDIA NvNeural SDK  2022.2
GPU inference framework for NVIDIA Nsight Deep Learning Designer
PluginTypes.h
Go to the documentation of this file.
1 /*
2 * SPDX-FileCopyrightText: Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: MIT
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23 
25 
26 #ifndef NVNEURAL_PLUGINTYPES_H
27 #define NVNEURAL_PLUGINTYPES_H
28 
29 #include <nvneural/CoreTypes.h>
30 
31 namespace nvneural {
32 
40  class IPlugin : public IRefObject
41  {
42  public:
44  static const IRefObject::TypeId typeID = 0x1ac7814b0a47cf4ful;
45 
52  virtual NeuralResult createObject(IRefObject** ppOut, const char* pObjectClass) const noexcept = 0;
53 
60  virtual NeuralResult setDefaultLogger(ILogger* pLogger) noexcept = 0;
61 
69  virtual const char* pluginName() const noexcept = 0;
70 
81  virtual const char* pluginVersion() const noexcept = 0;
82 
90  virtual const char* pluginAuthor() const noexcept = 0;
91 
97  virtual const char* pluginDescription() const noexcept = 0;
98  };
99 
102  class ILayerPlugin : public IRefObject
103  {
104  public:
106  static const IRefObject::TypeId typeID = 0xaa0b0fdbb7cf6616ul;
107 
112  virtual std::size_t getLayerDescCount() const noexcept = 0;
113 
120  virtual const LayerDesc* getLayerDesc(std::size_t layerIndex) const noexcept = 0;
121 
126  virtual std::size_t getFusingRuleCount() const noexcept = 0;
127 
134  virtual const FusingRule* getFusingRule(std::size_t fusingRuleIndex) const noexcept = 0;
135  };
136 
140  {
141  public:
143  static const IRefObject::TypeId typeID = 0xfe4bd876f03c7b1dul;
144 
149  virtual std::size_t getActivationDescCount() const noexcept = 0;
150 
157  virtual const ActivationDesc* getActivationDesc(std::size_t activationIndex) const noexcept = 0;
158  };
159 
163  {
164  public:
166  static const IRefObject::TypeId typeID = 0x55309c8928361be1ul;
167 
172  virtual std::size_t getPrototypeDescCount() const noexcept = 0;
173 
180  virtual const PrototypeDesc* getPrototypeDesc(std::size_t prototypeIndex) const noexcept = 0;
181 
188  virtual PrototypeRuntimeValidatorFunction getPrototypeRuntimeValidator(std::size_t prototypeIndex) const noexcept = 0;
189  };
190 
196  extern "C" using NvNeuralCreatePluginV1_Func = NeuralResult(*)(IPlugin** ppPluginOut) noexcept;
197 
199  class IPluginLoader : public IRefObject
200  {
201  public:
203  static const IRefObject::TypeId typeID = 0x8c3c1cd6b49fa3eaul;
204 
212  virtual NeuralResult loadLibrary(const char* pFilename, IPlugin** ppPluginOut) noexcept = 0;
213 
218  virtual NeuralResult loadDirectory(const char* pPathname, std::uint32_t* pNumberLoadedOut) noexcept = 0;
219 
223  virtual NeuralResult releasePlugin(IPlugin* pPlugin) noexcept = 0;
224 
228  virtual NeuralResult releaseAllPlugins() noexcept = 0;
229 
231  virtual std::size_t pluginCount() const noexcept = 0;
232 
238  virtual IPlugin* getPluginByIndex(std::size_t pluginIndex) const noexcept = 0;
239 
246  virtual NeuralResult getPluginPath(const IPlugin* pPlugin, const char** ppPluginPathOut) const noexcept = 0;
247 
251  virtual void allowIncompatiblePlugins() noexcept = 0;
252  };
253 }
254 
255 #endif // NVNEURAL_PLUGINTYPES_H
Fundamental NvNeural data types are declared here.
NeuralResult
NeuralResult is a generic success/failure result type similar to COM HRESULT.
Definition: CoreTypes.h:275
NeuralResult(*)(IPlugin **ppPluginOut) noexcept NvNeuralCreatePluginV1_Func
Entry point used to create an IPlugin object.
Definition: PluginTypes.h:196
IActivationPlugin is an optional interface implemented by IPlugin objects that describes generic (non...
Definition: PluginTypes.h:140
virtual std::size_t getActivationDescCount() const noexcept=0
Returns the number of ActivationDesc objects accessible through this interface.
ILayerPlugin is an optional interface implemented by IPlugin objects that describes layers implemente...
Definition: PluginTypes.h:103
virtual std::size_t getLayerDescCount() const noexcept=0
Returns the number of LayerDesc objects accessible through this interface.
Logger interface class.
Definition: CoreTypes.h:414
IPlugin is the general factory interface used by NvNeural's plugin system.
Definition: PluginTypes.h:41
virtual NeuralResult createObject(IRefObject **ppOut, const char *pObjectClass) const noexcept=0
Creates the designated object using its manifest-specified class name.
virtual const char * pluginAuthor() const noexcept=0
Returns a pointer to a UTF-8-encoded author name.
static const IRefObject::TypeId typeID
Interface TypeId for InterfaceOf purposes.
Definition: PluginTypes.h:44
virtual const char * pluginVersion() const noexcept=0
Returns a pointer to a UTF-8-encoded version string.
virtual const char * pluginDescription() const noexcept=0
Returns a pointer to a UTF-8-encoded plugin description.
virtual const char * pluginName() const noexcept=0
Returns a pointer to a UTF-8-encoded plugin name.
virtual NeuralResult setDefaultLogger(ILogger *pLogger) noexcept=0
Sets the default logger for the plugin to the specified backend.
Platform-agnostic plugin loader interface.
Definition: PluginTypes.h:200
virtual NeuralResult releasePlugin(IPlugin *pPlugin) noexcept=0
Releases the internal reference to a given plugin object and frees the library.
virtual NeuralResult loadLibrary(const char *pFilename, IPlugin **ppPluginOut) noexcept=0
Loads a plugin from a specific shared library file.
virtual NeuralResult loadDirectory(const char *pPathname, std::uint32_t *pNumberLoadedOut) noexcept=0
Loads all compatible plugins from the provided directory.
virtual NeuralResult releaseAllPlugins() noexcept=0
Releases all plugins tracked by this object.
IPrototypePlugin is an optional interface implemented by IPlugin objects that describes generic proto...
Definition: PluginTypes.h:163
virtual std::size_t getPrototypeDescCount() const noexcept=0
Returns the number of PrototypeDesc objects accessible through this interface.
Base class for all objects, similar to COM's IUnknown.
Definition: CoreTypes.h:343
std::uint64_t TypeId
Every interface must define a unique TypeId. This should be randomized.
Definition: CoreTypes.h:349
Structure describing an activation function (IActivationFunction) for tool interfaces and network bui...
Definition: CoreTypes.h:1634
Defines a fusing rule that can be applied during model loading.
Definition: CoreTypes.h:1781
This structure describes an ILayer for tools and network builders.
Definition: CoreTypes.h:1554
This structure represent a prototype layer version (backend, tensor format and kernel type),...
Definition: CoreTypes.h:1697