TensorRT 8.4.3
NvInferSafeRuntime.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 1993-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4 *
5 * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6 * property and proprietary rights in and to this material, related
7 * documentation and any modifications thereto. Any use, reproduction,
8 * disclosure or distribution of this material and related documentation
9 * without an express license agreement from NVIDIA CORPORATION or
10 * its affiliates is strictly prohibited.
11 */
12
13#ifndef NV_INFER_SAFE_RUNTIME_H
14#define NV_INFER_SAFE_RUNTIME_H
15
17#include <cstddef>
18#include <cstdint>
19
24
30namespace nvinfer1
31{
37namespace safe
38{
40class ICudaEngine;
42class IExecutionContext;
43
55{
56public:
76 virtual ICudaEngine* deserializeCudaEngine(void const* const blob, std::size_t const size) noexcept = 0;
77
91 virtual void setGpuAllocator(IGpuAllocator* const allocator) noexcept = 0;
92
102 //
109 virtual void setErrorRecorder(IErrorRecorder* const recorder) noexcept = 0;
110
125 virtual IErrorRecorder* getErrorRecorder() const noexcept = 0;
126
127 IRuntime() = default;
128 virtual ~IRuntime() noexcept = default;
129 IRuntime(IRuntime const&) = delete;
130 IRuntime(IRuntime&&) = delete;
131 IRuntime& operator=(IRuntime const&) & = delete;
132 IRuntime& operator=(IRuntime&&) & = delete;
133};
134
143{
144public:
154 virtual std::int32_t getNbBindings() const noexcept = 0;
155
176 virtual std::int32_t getBindingIndex(AsciiChar const* const name) const noexcept = 0;
177
192 virtual AsciiChar const* getBindingName(std::int32_t const bindingIndex) const noexcept = 0;
193
206 virtual bool bindingIsInput(std::int32_t const bindingIndex) const noexcept = 0;
207
220 virtual Dims getBindingDimensions(std::int32_t const bindingIndex) const noexcept = 0;
221
234 virtual DataType getBindingDataType(std::int32_t const bindingIndex) const noexcept = 0;
235
247 virtual IExecutionContext* createExecutionContext() noexcept = 0;
248
262 virtual IExecutionContext* createExecutionContextWithoutDeviceMemory() noexcept = 0;
263
273 virtual size_t getDeviceMemorySize() const noexcept = 0;
274
288 virtual std::int32_t getBindingBytesPerComponent(std::int32_t const bindingIndex) const noexcept = 0;
289
303 virtual std::int32_t getBindingComponentsPerElement(std::int32_t const bindingIndex) const noexcept = 0;
304
314 virtual TensorFormat getBindingFormat(std::int32_t const bindingIndex) const noexcept = 0;
315
327 virtual std::int32_t getBindingVectorizedDim(std::int32_t const bindingIndex) const noexcept = 0;
328
343 virtual AsciiChar const* getName() const noexcept = 0;
344
354 //
361 virtual void setErrorRecorder(IErrorRecorder* const recorder) noexcept = 0;
362
378 virtual IErrorRecorder* getErrorRecorder() const noexcept = 0;
379
380 ICudaEngine() = default;
381 virtual ~ICudaEngine() noexcept = default;
382 ICudaEngine(ICudaEngine const&) = delete;
384 ICudaEngine& operator=(ICudaEngine const&) & = delete;
385 ICudaEngine& operator=(ICudaEngine&&) & = delete;
386};
387
395{
397 int32_t nbNanErrors;
399 int32_t nbInfErrors;
400};
401
416{
417public:
427 virtual ICudaEngine const& getEngine() const noexcept = 0;
428
443 virtual void setName(AsciiChar const* const name) noexcept = 0;
444
454 virtual AsciiChar const* getName() const noexcept = 0;
455
471 virtual void setDeviceMemory(void* const memory) noexcept = 0;
472
482 virtual Dims getStrides(std::int32_t const bindingIndex) const noexcept = 0;
483
493 //
500 virtual void setErrorRecorder(IErrorRecorder* const recorder) noexcept = 0;
501
516 virtual IErrorRecorder* getErrorRecorder() const noexcept = 0;
517
537 virtual bool enqueueV2(
538 void* const* const bindings, cudaStream_t const stream, cudaEvent_t* const inputConsumed) noexcept
539 = 0;
540
541 IExecutionContext() = default;
542 virtual ~IExecutionContext() noexcept = default;
545 IExecutionContext& operator=(IExecutionContext const&) & = delete;
546 IExecutionContext& operator=(IExecutionContext&&) & = delete;
547
567 virtual void setErrorBuffer(FloatingPointErrorInformation* const buffer) noexcept = 0;
568
580 virtual FloatingPointErrorInformation* getErrorBuffer() const noexcept = 0;
581};
582
593
602
614template <typename T>
616{
617public:
619 {
620 getSafePluginRegistry()->registerCreator(instance, "");
621 }
622
623private:
625 T instance{};
626};
627
628} // namespace safe
629
630} // namespace nvinfer1
631
632#define REGISTER_SAFE_TENSORRT_PLUGIN(name) \
633 static nvinfer1::safe::PluginRegistrar<name> pluginRegistrar##name {}
634#endif // NV_INFER_SAFE_RUNTIME_H
#define TENSORRTAPI
Definition: NvInferRuntimeCommon.h:54
Definition: NvInferRuntimeCommon.h:153
Reference counted application-implemented error reporting interface for TensorRT objects.
Definition: NvInferRuntimeCommon.h:1665
Application-implemented class for controlling allocation on the GPU.
Definition: NvInferRuntimeCommon.h:1338
Application-implemented logging interface for the builder, refitter and runtime.
Definition: NvInferRuntimeCommon.h:1476
Single registration point for all plugins in an application. It is used to find plugin implementation...
Definition: NvInferRuntimeCommon.h:1210
virtual bool registerCreator(IPluginCreator &creator, AsciiChar const *const pluginNamespace) noexcept=0
Register a plugin creator. Returns false if one with same type is already registered.
A functionally safe engine for executing inference on a built network.
Definition: NvInferSafeRuntime.h:143
virtual std::int32_t getNbBindings() const noexcept=0
Get the number of binding indices.
Functionally safe context for executing inference using an engine.
Definition: NvInferSafeRuntime.h:416
virtual ICudaEngine const & getEngine() const noexcept=0
Get the associated engine.
Allows a serialized functionally safe engine to be deserialized.
Definition: NvInferSafeRuntime.h:55
virtual ICudaEngine * deserializeCudaEngine(void const *const blob, std::size_t const size) noexcept=0
Deserialize an engine from a stream.
virtual IErrorRecorder * getErrorRecorder() const noexcept=0
Get the ErrorRecorder assigned to this interface.
virtual void setGpuAllocator(IGpuAllocator *const allocator) noexcept=0
Set the GPU allocator.
virtual void setErrorRecorder(IErrorRecorder *const recorder) noexcept=0
Set the ErrorRecorder for this interface.
Register the plugin creator to the registry The static registry object will be instantiated when the ...
Definition: NvInferSafeRuntime.h:616
PluginRegistrar()
Definition: NvInferSafeRuntime.h:618
IRuntime * createInferRuntime(ILogger &logger) noexcept
Create an instance of an safe::IRuntime class.
nvinfer1::IPluginRegistry * getSafePluginRegistry() noexcept
Return the safe plugin registry.
The TensorRT API version 1 namespace.
char_t AsciiChar
AsciiChar is the type used by TensorRT to represent valid ASCII characters.
Definition: NvInferRuntimeCommon.h:88
DataType
The type of weights and tensors.
Definition: NvInferRuntimeCommon.h:114
TensorFormat
Format of the input/output tensors.
Definition: NvInferRuntimeCommon.h:183
Space to record information about floating point runtime errors.
Definition: NvInferSafeRuntime.h:395
int32_t nbInfErrors
Total count of errors relating to INF values (0 if none)
Definition: NvInferSafeRuntime.h:399
int32_t nbNanErrors
Total count of errors relating to NAN values (0 if none)
Definition: NvInferSafeRuntime.h:397

  Copyright © 2024 NVIDIA Corporation
  Privacy Policy | Manage My Privacy | Do Not Sell or Share My Data | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact