File size: 13,229 Bytes
38fb1f6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | /*
* SPDX-FileCopyrightText: Copyright (c) 1993-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NV_INFER_RUNTIME_COMMON_H
#define NV_INFER_RUNTIME_COMMON_H
//!
//! \file NvInferRuntimeCommon.h
//!
//! This file provides the nvinfer1::IPluginRegistry interface, which will be moved to the NvInferRuntime.h header
//! in a future release.
//!
//! \warning This file will be removed in a future release.
//!
//! \warning Do not directly include this file. Instead include NvInferRuntime.h
//!
#define NV_INFER_INTERNAL_INCLUDE 1
#include "NvInferPluginBase.h"
#undef NV_INFER_INTERNAL_INCLUDE
#include "NvInferRuntimePlugin.h"
namespace nvinfer1
{
//!
//! \class IPluginRegistry
//!
//! \brief Single registration point for all plugins in an application. It is
//! used to find plugin implementations during engine deserialization.
//! Internally, the plugin registry is considered to be a singleton so all
//! plugins in an application are part of the same global registry.
//! Note that the plugin registry is only supported for plugins of type
//! IPluginV2 and should also have a corresponding IPluginCreator implementation.
//!
//! \see IPluginV2 and IPluginCreator
//!
//! \warning Do not inherit from this class, as doing so will break forward-compatibility of the API and ABI.
//!
//! \warning In the automotive safety context, be sure to call IPluginRegistry::setErrorRecorder() to register
//! an error recorder with the registry before using other methods in the registry.
//!
class IPluginRegistry
{
public:
//!
//! \brief Pointer for plugin library handle.
//!
using PluginLibraryHandle = void*;
//!
//! \brief Register a plugin creator implementing IPluginCreator. Returns false if any plugin creator with the same
//! name, version or namespace is already registered.
//!
//! \warning The string pluginNamespace must be 1024 bytes or less including the NULL terminator and must be NULL
//! terminated.
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: Yes; calls to this method will be synchronized by a mutex.
//!
//! \deprecated Deprecated in TensorRT 10.0. Superseded by
//! IPluginRegistry::registerCreator(IPluginCreatorInterface&, AsciiChar const* const).
//!
TRT_DEPRECATED virtual bool registerCreator(
IPluginCreator& creator, AsciiChar const* const pluginNamespace) noexcept = 0;
//!
//! \brief Return all the registered plugin creators and the number of
//! registered plugin creators. Returns nullptr if none found.
//!
//! \warning If any plugin creators are registered or deregistered after calling this function, the returned pointer
//! is not guaranteed to be valid thereafter.
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: No
//!
//! \deprecated Deprecated in TensorRT 10.0. Superseded by IPluginRegistry::getAllCreators(int32_t* const).
//!
TRT_DEPRECATED virtual IPluginCreator* const* getPluginCreatorList(int32_t* const numCreators) const noexcept = 0;
//!
//! \brief Return plugin creator based on plugin name, version, and
//! namespace associated with plugin during network creation.
//!
//! \warning The strings pluginName, pluginVersion, and pluginNamespace must be 1024 bytes or less including the
//! NULL terminator and must be NULL terminated.
//!
//! \warning Returns nullptr if a plugin creator with matching name, version, and namespace is found, but is not a
//! descendent of IPluginCreator
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: Yes
//!
//! \deprecated Deprecated in TensorRT 10.0. Superseded by IPluginRegistry::getCreator(AsciiChar const* const,
//! AsciiChar const* const, AsciiChar const* const).
//!
TRT_DEPRECATED virtual IPluginCreator* getPluginCreator(AsciiChar const* const pluginName,
AsciiChar const* const pluginVersion, AsciiChar const* const pluginNamespace = "") noexcept = 0;
// @cond SuppressDoxyWarnings
IPluginRegistry() = default;
IPluginRegistry(IPluginRegistry const&) = delete;
IPluginRegistry(IPluginRegistry&&) = delete;
IPluginRegistry& operator=(IPluginRegistry const&) & = delete;
IPluginRegistry& operator=(IPluginRegistry&&) & = delete;
// @endcond
protected:
virtual ~IPluginRegistry() noexcept = default;
public:
//!
//! \brief Set the ErrorRecorder for this interface
//!
//! Assigns the ErrorRecorder to this interface. The ErrorRecorder will track all errors during execution.
//! This function will call incRefCount of the registered ErrorRecorder at least once. Setting
//! recorder to nullptr unregisters the recorder with the interface, resulting in a call to decRefCount if
//! a recorder has been registered.
//!
//! \param recorder The error recorder to register with this interface.
//!
//! \see getErrorRecorder()
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: No
//!
virtual void setErrorRecorder(IErrorRecorder* const recorder) noexcept = 0;
//!
//! \brief Get the ErrorRecorder assigned to this interface.
//!
//! Retrieves the assigned error recorder object for the given class. A default error recorder does not exist,
//! so a nullptr will be returned if setErrorRecorder has not been called, or an ErrorRecorder has not been
//! inherited.
//!
//! \return A pointer to the IErrorRecorder object that has been registered.
//!
//! \see setErrorRecorder()
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: Yes
//!
virtual IErrorRecorder* getErrorRecorder() const noexcept = 0;
//!
//! \brief Deregister a previously registered plugin creator implementing IPluginCreator.
//!
//! Since there may be a desire to limit the number of plugins,
//! this function provides a mechanism for removing plugin creators registered in TensorRT.
//! The plugin creator that is specified by \p creator is removed from TensorRT and no longer tracked.
//!
//! \return True if the plugin creator was deregistered, false if it was not found in the registry or otherwise
//! could not be deregistered.
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: Yes
//!
//! \deprecated Deprecated in TensorRT 10.0. Superseded by
//! IPluginRegistry::deregisterCreator(IPluginCreatorInterface const&).
//!
TRT_DEPRECATED virtual bool deregisterCreator(IPluginCreator const& creator) noexcept = 0;
//!
//! \brief Return whether the parent registry will be searched if a plugin is not found in this registry
//! default: true
//!
//! \return bool variable indicating whether parent search is enabled.
//!
//! \see setParentSearchEnabled
//!
virtual bool isParentSearchEnabled() const = 0;
//!
//! \brief Set whether the parent registry will be searched if a plugin is not found in this registry.
//!
//! \param enabled The bool variable indicating whether parent search is enabled.
//!
//! \see isParentSearchEnabled
//!
virtual void setParentSearchEnabled(bool const enabled) = 0;
//!
//! \brief Load and register a shared library of plugins.
//!
//! \param pluginPath the plugin library path.
//!
//! \return The loaded plugin library handle. The call will fail and return
//! nullptr if any of the plugins are already registered.
//!
virtual PluginLibraryHandle loadLibrary(AsciiChar const* pluginPath) noexcept = 0;
//!
//! \brief Deregister plugins associated with a library. Any resources acquired when the library
//! was loaded will be released.
//!
//! \param handle the plugin library handle to deregister.
//!
virtual void deregisterLibrary(PluginLibraryHandle handle) noexcept = 0;
//!
//! \brief Register a plugin creator. Returns false if a plugin creator with the same type
//! is already registered.
//!
//! \warning The string pluginNamespace must be 1024 bytes or less including the NULL terminator and must be NULL
//! terminated.
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: Yes; calls to this method will be synchronized by a mutex.
//!
virtual bool registerCreator(IPluginCreatorInterface& creator, AsciiChar const* const pluginNamespace) noexcept = 0;
//!
//! \brief Return all registered plugin creators. Returns nullptr if none found.
//!
//! \warning If any plugin creators are registered or deregistered after calling this function, the returned pointer
//! is not guaranteed to be valid thereafter.
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: No
//!
virtual IPluginCreatorInterface* const* getAllCreators(int32_t* const numCreators) const noexcept = 0;
//!
//! \brief Return a registered plugin creator based on plugin name, version, and namespace associated with the
//! plugin during network creation.
//!
//! \warning The strings pluginName, pluginVersion, and pluginNamespace must be 1024 bytes or less including the
//! NULL terminator and must be NULL terminated.
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: Yes
//!
virtual IPluginCreatorInterface* getCreator(AsciiChar const* const pluginName, AsciiChar const* const pluginVersion,
AsciiChar const* const pluginNamespace = "") noexcept = 0;
//!
//! \brief Deregister a previously registered plugin creator.
//!
//! Since there may be a desire to limit the number of plugins,
//! this function provides a mechanism for removing plugin creators registered in TensorRT.
//! The plugin creator that is specified by \p creator is removed from TensorRT and no longer tracked.
//!
//! \return True if the plugin creator was deregistered, false if it was not found in the registry or otherwise
//! could not be deregistered.
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: Yes
//!
virtual bool deregisterCreator(IPluginCreatorInterface const& creator) noexcept = 0;
//!
//! \brief Get a plugin resource
//! \param key Key for identifying the resource. Cannot be null.
//! \param resource A plugin resource object. The object will only need to be valid until this method returns, as
//! only a clone of this object will be registered by TRT. Cannot be null.
//!
//! \return Registered plugin resource object
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: Yes; calls to this method will be synchronized by a mutex.
//!
virtual IPluginResource* acquirePluginResource(AsciiChar const* key, IPluginResource* resource) noexcept = 0;
//!
//! \brief Decrement reference count for the resource with this key
//! If reference count goes to zero after decrement, release() will be invoked on the resource, the key will
//! be deregistered and the resource object will be deleted
//!
//! \param key Key that was used to register the resource. Cannot be null.
//!
//! \return 0 for success, else non-zero
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: Yes; calls to this method will be synchronized by a mutex.
//!
virtual int32_t releasePluginResource(AsciiChar const* key) noexcept = 0;
//!
//! \brief Return all registered plugin creators by searching starting from the current registry and following
//! parent registries recursively as long as isParentSearchEnabled() returns true.
//!
//! \param[out] numCreators Pointer to an integer where the number of registered plugin creators will be stored.
//!
//! \return A pointer to an array of IPluginCreatorInterface pointers. Returns nullptr if no creators are found.
//!
//! \warning If any plugin creators are registered or deregistered after calling this function, the returned pointer
//! is not guaranteed to remain valid.
//!
//! \usage
//! - Allowed context for the API call
//! - Thread-safe: No
//!
virtual IPluginCreatorInterface* const* getAllCreatorsRecursive(int32_t* const numCreators) noexcept = 0;
};
} // namespace nvinfer1
#endif /* NV_INFER_RUNTIME_COMMON_H */
|