TensorRT 11.5.0
NvInferRuntimeBase.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 1993-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef NV_INFER_RUNTIME_BASE_H
19#define NV_INFER_RUNTIME_BASE_H
20
21#include "NvInferVersion.h"
22#include <cstddef>
23#include <cstdint>
24#include <cuda_runtime_api.h>
25
26// Expands to no tokens.
27// {$nv-internal-release begin}
28// Token pasting makes compatibility macros eligible for the MISRA C++:2023
29// Rule 19.0.2 exception without changing their final expansion. It also avoids Coverity 2025.6.0
30// false positives for object-like macros whose replacement lists contain parentheses.
31// {$nv-internal-release end}
32#define TRT_DETAIL_EMPTY
33
34// Items that are marked as deprecated will be removed in a future release.
35#if __cplusplus >= 201402L
36#define TRT_DEPRECATED [[deprecated]]
37#define TRT_DEPRECATED_BECAUSE(REASON) [[deprecated(REASON)]] TRT_DETAIL##_EMPTY
38#define TRT_DEPRECATED_ENUM TRT_DEPRECATED
39#ifdef _MSC_VER
40#define TRT_DEPRECATED_API __declspec(dllexport) TRT_DETAIL##_EMPTY
41#else
42#define TRT_DEPRECATED_API [[deprecated]] __attribute__((visibility("default"))) TRT_DETAIL##_EMPTY
43#endif
44#else
45#ifdef _MSC_VER
46#define TRT_DEPRECATED
47#define TRT_DEPRECATED_ENUM
48#define TRT_DEPRECATED_API __declspec(dllexport) TRT_DETAIL##_EMPTY
49#else
50#define TRT_DEPRECATED __attribute__((deprecated)) TRT_DETAIL##_EMPTY
51#define TRT_DEPRECATED_ENUM
52#define TRT_DEPRECATED_API __attribute__((deprecated, visibility("default"))) TRT_DETAIL##_EMPTY
53#endif
54#define TRT_DEPRECATED_BECAUSE(REASON) TRT_DEPRECATED TRT_DETAIL##_EMPTY
55#endif
56
58#if __cplusplus >= 201907L
59#define TRT_NODISCARD [[nodiscard]]
60#define TRT_NODISCARD_BECAUSE(REASON) [[nodiscard(REASON)]] TRT_DETAIL##_EMPTY
61#elif __cplusplus >= 201603L
62#define TRT_NODISCARD [[nodiscard]]
63#define TRT_NODISCARD_BECAUSE(REASON) [[nodiscard]] TRT_DETAIL##_EMPTY
64#else
65#define TRT_NODISCARD
66#define TRT_NODISCARD_BECAUSE(REASON) TRT_DETAIL##_EMPTY
67#endif
68
69// Defines which symbols are exported.
70#ifdef TENSORRT_BUILD_LIB
71#ifdef _MSC_VER
72// On Windows, exports are controlled by .def files; not by dllexport.
73#define TENSORRTAPI
74#else
75#define TENSORRTAPI __attribute__((visibility("default"))) TRT_DETAIL##_EMPTY
76#endif
77#else
78#define TENSORRTAPI
79#endif
80#define TRTNOEXCEPT
90#if !defined(NV_INFER_INTERNAL_INCLUDE)
91static_assert(false, "Do not directly include this file. Include NvInferRuntime.h or NvInferPluginUtils.h");
92#endif
93
95
96extern "C"
97{
99 struct cublasContext;
101 struct cudnnContext;
102}
103
106#define NV_TENSORRT_VERSION_INT(major, minor, patch) \
107 ((major) * 10000L + (minor) * 100L + (patch) * 1L) TRT_DETAIL##_EMPTY
108
111#define NV_TENSORRT_VERSION \
112 NV_TENSORRT_VERSION_INT(NV_TENSORRT_MAJOR, NV_TENSORRT_MINOR, NV_TENSORRT_PATCH) TRT_DETAIL##_EMPTY
113
119namespace nvinfer1
120{
122using char_t = char;
123
127
129namespace v_1_0
130{
131class IErrorRecorder;
132class ILogger;
133} // namespace v_1_0
136
137namespace impl
138{
140template <typename T>
142{
143};
144} // namespace impl
145
148template <typename T>
149constexpr int32_t EnumMax() noexcept
150{
152}
153
160enum class DataType : int32_t
161{
163 kFLOAT = 0,
164
166 kHALF = 1,
167
169 kINT8 = 2,
170
172 kINT32 = 3,
173
175 kBOOL = 4,
176
189 kUINT8 = 5,
190
193 kFP8 = 6,
194
196 kBF16 = 7,
197
199 kINT64 = 8,
200
202 kINT4 = 9,
203
206 kFP4 = 10,
207
209 kE8M0 = 11,
210};
211
212namespace impl
213{
215template <>
217{
219 static constexpr int32_t kVALUE = 12;
220};
221} // namespace impl
222
234{
235public:
237 static constexpr int32_t MAX_DIMS{8};
238
240 int32_t nbDims;
241
243 int64_t d[MAX_DIMS];
244};
245
249using Dims = Dims64;
250
251using InterfaceKind = char const*;
252
258{
259public:
261 int32_t major;
262 int32_t minor;
263};
264
269enum class APILanguage : int32_t
270{
271 kCPP = 0,
272 kPYTHON = 1
273};
274
275namespace impl
276{
278template <>
280{
282 static constexpr int32_t kVALUE = 2;
283};
284} // namespace impl
285
291// coverity[misra_cpp_2023_rule_15_0_1_violation] TID-5115 allowed for IVersionedInterface {$nv-internal-release}
293{
294public:
300 virtual APILanguage getAPILanguage() const noexcept
301 {
302 return APILanguage::kCPP;
303 }
304
308 virtual InterfaceInfo getInterfaceInfo() const noexcept = 0;
309
310 virtual ~IVersionedInterface() noexcept = default;
311
312protected:
316 IVersionedInterface& operator=(IVersionedInterface const&) & = default;
317 IVersionedInterface& operator=(IVersionedInterface&&) & = default;
318};
319
325enum class ErrorCode : int32_t
326{
330 kSUCCESS = 0,
331
336
341 kINTERNAL_ERROR = 2,
342
348
356 kINVALID_CONFIG = 4,
357
364
370
378
387
400 kINVALID_STATE = 9,
401
413
414};
415
416namespace impl
417{
419template <>
421{
423 static constexpr int32_t kVALUE = 11;
424};
425} // namespace impl
426
427namespace v_1_0
428{
433{
434public:
438 InterfaceInfo getInterfaceInfo() const noexcept override
439 {
440 return InterfaceInfo{"IErrorRecorder", 1, 0};
441 }
442
446 using ErrorDesc = char const*;
447
453 static constexpr size_t kMAX_DESC_LENGTH{127U};
454
458 using RefCount = int32_t;
459
460 IErrorRecorder() = default;
461 ~IErrorRecorder() noexcept override = default;
462
463 // Public API used to retrieve information from the error recorder.
464
488 virtual int32_t getNbErrors() const noexcept = 0;
489
508 virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
509
531 virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
532
548 virtual bool hasOverflowed() const noexcept = 0;
549
564 virtual void clear() noexcept = 0;
565
566 // API used by TensorRT to report Error information to the application.
567
594 virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept = 0;
595
612 virtual RefCount incRefCount() noexcept = 0;
613
630 virtual RefCount decRefCount() noexcept = 0;
631
632protected:
633 // @cond SuppressDoxyWarnings
634 IErrorRecorder(IErrorRecorder const&) = default;
635 IErrorRecorder(IErrorRecorder&&) = default;
636 IErrorRecorder& operator=(IErrorRecorder const&) & = default;
637 IErrorRecorder& operator=(IErrorRecorder&&) & = default;
638 // @endcond
639}; // class IErrorRecorder
640} // namespace v_1_0
641
669using IErrorRecorder = v_1_0::IErrorRecorder;
670
676enum class TensorIOMode : int32_t
677{
679 kNONE = 0,
680
682 kINPUT = 1,
683
685 kOUTPUT = 2
686};
687
688namespace impl
689{
691template <>
693{
694 // One greater than the maximum value of TensorIOMode enum
695 static constexpr int32_t kVALUE = 3;
696};
697} // namespace impl
698} // namespace nvinfer1
699
705extern "C" TENSORRTAPI int32_t getInferLibVersion() noexcept;
706
707#endif // NV_INFER_RUNTIME_BASE_H
#define TENSORRTAPI
Definition: NvInferRuntimeBase.h:78
TENSORRTAPI int32_t getInferLibVersion() noexcept
Return the library version number.
Definition: NvInferRuntimeBase.h:234
static constexpr int32_t MAX_DIMS
The maximum rank (number of dimensions) supported for a tensor.
Definition: NvInferRuntimeBase.h:237
int64_t d[MAX_DIMS]
The extent of each dimension.
Definition: NvInferRuntimeBase.h:243
int32_t nbDims
The rank (number of dimensions).
Definition: NvInferRuntimeBase.h:240
An Interface class for version control.
Definition: NvInferRuntimeBase.h:293
virtual InterfaceInfo getInterfaceInfo() const noexcept=0
Return version information associated with this interface. Applications must not override this method...
virtual APILanguage getAPILanguage() const noexcept
The language used to build the implementation of this Interface.
Definition: NvInferRuntimeBase.h:300
Holds version and kind information for a TensorRT interface.
Definition: NvInferRuntimeBase.h:258
InterfaceKind kind
Interface identifier. Must remain valid for use.
Definition: NvInferRuntimeBase.h:260
int32_t major
Definition: NvInferRuntimeBase.h:261
int32_t minor
Definition: NvInferRuntimeBase.h:262
Interface for recording and querying errors reported by TensorRT.
Definition: NvInferRuntimeBase.h:433
char const * ErrorDesc
A typedef of a C-style string for reporting error descriptions.
Definition: NvInferRuntimeBase.h:446
~IErrorRecorder() noexcept override=default
int32_t RefCount
A typedef of a 32-bit integer for reference counting.
Definition: NvInferRuntimeBase.h:458
InterfaceInfo getInterfaceInfo() const noexcept override
Return version information associated with this interface. Applications must not override this method...
Definition: NvInferRuntimeBase.h:438
Application-implemented logging interface for the builder, refitter and runtime.
Definition: NvInferRuntime.h:1614
The TensorRT API version 1 namespace.
Definition: NvInferSafePlugin.h:33
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeBase.h:326
TensorIOMode
Definition of tensor IO Mode.
Definition: NvInferRuntimeBase.h:677
@ kOUTPUT
Tensor is output by the engine.
@ kINPUT
Tensor is input to the engine.
APILanguage
Programming language used in the implementation of a TensorRT interface.
Definition: NvInferRuntimeBase.h:270
v_1_0::ILogger ILogger
Definition: NvInferRuntimeBase.h:135
char_t AsciiChar
Definition: NvInferRuntimeBase.h:126
char char_t
char_t is the type used by TensorRT to represent all valid characters.
Definition: NvInferRuntimeBase.h:122
DataType
The type of weights and tensors. The datatypes other than kBOOL, kINT32, and kINT64 are "activation d...
Definition: NvInferRuntimeBase.h:161
@ kINT64
Signed 64-bit integer type.
@ kFLOAT
32-bit floating point format.
@ kBOOL
8-bit boolean. 0 = false, 1 = true, other values undefined.
@ kHALF
IEEE 16-bit floating-point format – has a 5 bit exponent and 11 bit significand.
@ kINT8
Signed 8-bit integer representing a quantized floating-point value.
@ kE8M0
Unsigned representation of exponent-only 8-bit floating point type for quantization scales.
@ kBF16
Brain float – has an 8 bit exponent and 8 bit significand.
@ kINT4
Signed 4-bit integer type.
@ kINT32
Signed 32-bit integer format.
char const * InterfaceKind
Definition: NvInferRuntimeBase.h:251
constexpr int32_t EnumMax() noexcept
Definition: NvInferRuntimeBase.h:149
v_1_0::IErrorRecorder IErrorRecorder
Definition: NvInferRuntimeBase.h:134
Declaration of EnumMaxImpl struct to store the exclusive upper bound of an enumeration type.
Definition: NvInferRuntimeBase.h:142

  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