TensorRT 8.5.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:
158 TRT_DEPRECATED virtual std::int32_t getNbBindings() const noexcept = 0;
159
181 TRT_DEPRECATED virtual std::int32_t getBindingIndex(AsciiChar const* const name) const noexcept = 0;
182
200 TRT_DEPRECATED virtual AsciiChar const* getBindingName(std::int32_t const bindingIndex) const noexcept = 0;
201
216 TRT_DEPRECATED virtual bool bindingIsInput(std::int32_t const bindingIndex) const noexcept = 0;
217
232 TRT_DEPRECATED virtual Dims getBindingDimensions(std::int32_t const bindingIndex) const noexcept = 0;
233
248 TRT_DEPRECATED virtual DataType getBindingDataType(std::int32_t const bindingIndex) const noexcept = 0;
249
261 virtual IExecutionContext* createExecutionContext() noexcept = 0;
262
276 virtual IExecutionContext* createExecutionContextWithoutDeviceMemory() noexcept = 0;
277
287 virtual size_t getDeviceMemorySize() const noexcept = 0;
288
304 TRT_DEPRECATED virtual std::int32_t getBindingBytesPerComponent(std::int32_t const bindingIndex) const noexcept = 0;
305
321 TRT_DEPRECATED virtual std::int32_t getBindingComponentsPerElement(std::int32_t const bindingIndex) const noexcept = 0;
322
336 TRT_DEPRECATED virtual TensorFormat getBindingFormat(std::int32_t const bindingIndex) const noexcept = 0;
337
353 TRT_DEPRECATED virtual std::int32_t getBindingVectorizedDim(std::int32_t const bindingIndex) const noexcept = 0;
354
369 virtual AsciiChar const* getName() const noexcept = 0;
370
380 //
387 virtual void setErrorRecorder(IErrorRecorder* const recorder) noexcept = 0;
388
404 virtual IErrorRecorder* getErrorRecorder() const noexcept = 0;
405
406 ICudaEngine() = default;
407 virtual ~ICudaEngine() noexcept = default;
408 ICudaEngine(ICudaEngine const&) = delete;
410 ICudaEngine& operator=(ICudaEngine const&) & = delete;
411 ICudaEngine& operator=(ICudaEngine&&) & = delete;
412
429 virtual Dims getTensorShape(AsciiChar const* tensorName) const noexcept = 0;
430
448 virtual DataType getTensorDataType(AsciiChar const* tensorName) const noexcept = 0;
449
464 virtual TensorIOMode getTensorIOMode(AsciiChar const* tensorName) const noexcept = 0;
465
486 virtual std::int32_t getTensorBytesPerComponent(AsciiChar const* tensorName) const noexcept = 0;
487
508 virtual std::int32_t getTensorComponentsPerElement(AsciiChar const* tensorName) const noexcept = 0;
509
527 virtual TensorFormat getTensorFormat(AsciiChar const* tensorName) const noexcept = 0;
528
549 virtual std::int32_t getTensorVectorizedDim(AsciiChar const* tensorName) const noexcept = 0;
550
562 virtual std::int32_t getNbIOTensors() const noexcept = 0;
563
581 virtual AsciiChar const* getIOTensorName(std::int32_t const index) const noexcept = 0;
582};
583
591{
593 int32_t nbNanErrors;
595 int32_t nbInfErrors;
596};
597
612{
613public:
623 virtual ICudaEngine const& getEngine() const noexcept = 0;
624
639 virtual void setName(AsciiChar const* const name) noexcept = 0;
640
650 virtual AsciiChar const* getName() const noexcept = 0;
651
667 virtual void setDeviceMemory(void* const memory) noexcept = 0;
668
682 TRT_DEPRECATED virtual Dims getStrides(std::int32_t const bindingIndex) const noexcept = 0;
683
693 //
700 virtual void setErrorRecorder(IErrorRecorder* const recorder) noexcept = 0;
701
716 virtual IErrorRecorder* getErrorRecorder() const noexcept = 0;
717
739 TRT_DEPRECATED virtual bool enqueueV2(
740 void* const* const bindings, cudaStream_t const stream, cudaEvent_t const* const inputConsumed) noexcept = 0;
741
742 IExecutionContext() = default;
743 virtual ~IExecutionContext() noexcept = default;
746 IExecutionContext& operator=(IExecutionContext const&) & = delete;
747 IExecutionContext& operator=(IExecutionContext&&) & = delete;
748
768 virtual void setErrorBuffer(FloatingPointErrorInformation* const buffer) noexcept = 0;
769
781 virtual FloatingPointErrorInformation* getErrorBuffer() const noexcept = 0;
782
803 virtual Dims getTensorStrides(AsciiChar const* tensorName) const noexcept = 0;
804
829 virtual bool setInputTensorAddress(AsciiChar const* tensorName, void const* data) noexcept = 0;
830
855 virtual bool setOutputTensorAddress(AsciiChar const* tensorName, void* data) noexcept = 0;
856
870 virtual bool setInputConsumedEvent(cudaEvent_t event) noexcept = 0;
871
881 virtual cudaEvent_t getInputConsumedEvent() const noexcept = 0;
882
901 virtual void const* getInputTensorAddress(AsciiChar const* tensorName) const noexcept = 0;
902
921 virtual void* getOutputTensorAddress(AsciiChar const* tensorName) const noexcept = 0;
922
938 virtual bool enqueueV3(cudaStream_t stream) noexcept = 0;
939};
940
951
960
972template <typename T>
974{
975public:
977 {
978 getSafePluginRegistry()->registerCreator(instance, "");
979 }
980
981private:
983 T instance{};
984};
985
986} // namespace safe
987
988} // namespace nvinfer1
989
990#define REGISTER_SAFE_TENSORRT_PLUGIN(name) \
991 static nvinfer1::safe::PluginRegistrar<name> pluginRegistrar##name {}
992#endif // NV_INFER_SAFE_RUNTIME_H
#define TENSORRTAPI
Definition: NvInferRuntimeCommon.h:54
#define TRT_DEPRECATED
Definition: NvInferRuntimeCommon.h:40
Definition: NvInferRuntimeCommon.h:171
Reference counted application-implemented error reporting interface for TensorRT objects.
Definition: NvInferRuntimeCommon.h:1689
Application-implemented class for controlling allocation on the GPU.
Definition: NvInferRuntimeCommon.h:1362
Application-implemented logging interface for the builder, refitter and runtime.
Definition: NvInferRuntimeCommon.h:1500
Single registration point for all plugins in an application. It is used to find plugin implementation...
Definition: NvInferRuntimeCommon.h:1234
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 TRT_DEPRECATED 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:612
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:974
PluginRegistrar()
Definition: NvInferSafeRuntime.h:976
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.
TensorIOMode
Definition of tensor IO Mode.
Definition: NvInferRuntimeCommon.h:1878
char_t AsciiChar
Definition: NvInferRuntimeCommon.h:91
DataType
The type of weights and tensors.
Definition: NvInferRuntimeCommon.h:117
TensorFormat
Format of the input/output tensors.
Definition: NvInferRuntimeCommon.h:201
Space to record information about floating point runtime errors.
Definition: NvInferSafeRuntime.h:591
int32_t nbInfErrors
Total count of errors relating to INF values (0 if none)
Definition: NvInferSafeRuntime.h:595
int32_t nbNanErrors
Total count of errors relating to NAN values (0 if none)
Definition: NvInferSafeRuntime.h:593

  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