TensorRT 11.0.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// Items that are marked as deprecated will be removed in a future release.
27#if __cplusplus >= 201402L
28#define TRT_DEPRECATED [[deprecated]]
29#define TRT_DEPRECATED_BECAUSE(REASON) [[deprecated(REASON)]]
30#define TRT_DEPRECATED_ENUM TRT_DEPRECATED
31#ifdef _MSC_VER
32#define TRT_DEPRECATED_API __declspec(dllexport)
33#else
34#define TRT_DEPRECATED_API [[deprecated]] __attribute__((visibility("default")))
35#endif
36#else
37#ifdef _MSC_VER
38#define TRT_DEPRECATED
39#define TRT_DEPRECATED_ENUM
40#define TRT_DEPRECATED_API __declspec(dllexport)
41#else
42#define TRT_DEPRECATED __attribute__((deprecated))
43#define TRT_DEPRECATED_ENUM
44#define TRT_DEPRECATED_API __attribute__((deprecated, visibility("default")))
45#endif
46#define TRT_DEPRECATED_BECAUSE(REASON) TRT_DEPRECATED
47#endif
48
50#if __cplusplus >= 201907L
51#define TRT_NODISCARD [[nodiscard]]
52#define TRT_NODISCARD_BECAUSE(REASON) [[nodiscard(REASON)]]
53#elif __cplusplus >= 201603L
54#define TRT_NODISCARD [[nodiscard]]
55#define TRT_NODISCARD_BECAUSE(REASON) [[nodiscard]]
56#else
57#define TRT_NODISCARD
58#define TRT_NODISCARD_BECAUSE(REASON)
59#endif
60
61// Defines which symbols are exported.
62#ifdef TENSORRT_BUILD_LIB
63#ifdef _MSC_VER
64//On Windows, exports are controlled by .def files; not by dllexport.
65#define TENSORRTAPI
66#else
67#define TENSORRTAPI __attribute__((visibility("default")))
68#endif
69#else
70#define TENSORRTAPI
71#endif
72#define TRTNOEXCEPT
82#if !defined(NV_INFER_INTERNAL_INCLUDE)
83static_assert(false, "Do not directly include this file. Include NvInferRuntime.h or NvInferPluginUtils.h");
84#endif
85
87
88extern "C"
89{
91 struct cublasContext;
93 struct cudnnContext;
94}
95
98#define NV_TENSORRT_VERSION_INT(major, minor, patch) ((major) *10000L + (minor) *100L + (patch) *1L)
99
102#define NV_TENSORRT_VERSION NV_TENSORRT_VERSION_INT(NV_TENSORRT_MAJOR, NV_TENSORRT_MINOR, NV_TENSORRT_PATCH)
103
109namespace nvinfer1
110{
112using char_t = char;
113
117
119namespace v_1_0
120{
121class IErrorRecorder;
122class ILogger;
123} // namespace v_1_0
126
127namespace impl
128{
130template <typename T>
132} // namespace impl
133
136template <typename T>
137constexpr int32_t EnumMax() noexcept
138{
140}
141
148enum class DataType : int32_t
149{
151 kFLOAT = 0,
152
154 kHALF = 1,
155
157 kINT8 = 2,
158
160 kINT32 = 3,
161
163 kBOOL = 4,
164
177 kUINT8 = 5,
178
181 kFP8 = 6,
182
184 kBF16 = 7,
185
187 kINT64 = 8,
188
190 kINT4 = 9,
191
194 kFP4 = 10,
195
197 kE8M0 = 11,
198};
199
200namespace impl
201{
203template <>
205{
207 static constexpr int32_t kVALUE = 12;
208};
209} // namespace impl
210
222{
223public:
225 static constexpr int32_t MAX_DIMS{8};
226
228 int32_t nbDims;
229
231 int64_t d[MAX_DIMS];
232};
233
237using Dims = Dims64;
238
239using InterfaceKind = char const*;
240
247{
248public:
250 int32_t major;
251 int32_t minor;
252};
253
259enum class APILanguage : int32_t
260{
261 kCPP = 0,
262 kPYTHON = 1
263};
264
265namespace impl
266{
268template <>
270{
272 static constexpr int32_t kVALUE = 2;
273};
274} // namespace impl
275
282{
283public:
289 virtual APILanguage getAPILanguage() const noexcept
290 {
291 return APILanguage::kCPP;
292 }
293
297 virtual InterfaceInfo getInterfaceInfo() const noexcept = 0;
298
299 virtual ~IVersionedInterface() noexcept = default;
300
301protected:
305 IVersionedInterface& operator=(IVersionedInterface const&) & = default;
306 IVersionedInterface& operator=(IVersionedInterface&&) & = default;
307};
308
314enum class ErrorCode : int32_t
315{
319 kSUCCESS = 0,
320
325
330 kINTERNAL_ERROR = 2,
331
337
345 kINVALID_CONFIG = 4,
346
353
359
367
376
389 kINVALID_STATE = 9,
390
402
403};
404
405namespace impl
406{
408template <>
410{
412 static constexpr int32_t kVALUE = 11;
413};
414} // namespace impl
415
416namespace v_1_0
417{
419{
420public:
424 InterfaceInfo getInterfaceInfo() const noexcept override
425 {
426 return InterfaceInfo{"IErrorRecorder", 1, 0};
427 }
428
432 using ErrorDesc = char const*;
433
439 static constexpr size_t kMAX_DESC_LENGTH{127U};
440
444 using RefCount = int32_t;
445
446 IErrorRecorder() = default;
447 ~IErrorRecorder() noexcept override = default;
448
449 // Public API used to retrieve information from the error recorder.
450
474 virtual int32_t getNbErrors() const noexcept = 0;
475
494 virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
495
517 virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
518
533 virtual bool hasOverflowed() const noexcept = 0;
534
549 virtual void clear() noexcept = 0;
550
551 // API used by TensorRT to report Error information to the application.
552
579 virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept = 0;
580
597 virtual RefCount incRefCount() noexcept = 0;
598
615 virtual RefCount decRefCount() noexcept = 0;
616
617protected:
618 // @cond SuppressDoxyWarnings
619 IErrorRecorder(IErrorRecorder const&) = default;
620 IErrorRecorder(IErrorRecorder&&) = default;
621 IErrorRecorder& operator=(IErrorRecorder const&) & = default;
622 IErrorRecorder& operator=(IErrorRecorder&&) & = default;
623 // @endcond
624}; // class IErrorRecorder
625} // namespace v_1_0
626
654using IErrorRecorder = v_1_0::IErrorRecorder;
655
661enum class TensorIOMode : int32_t
662{
664 kNONE = 0,
665
667 kINPUT = 1,
668
670 kOUTPUT = 2
671};
672
673namespace impl
674{
676template <>
678{
679 // One greater than the maximum value of TensorIOMode enum
680 static constexpr int32_t kVALUE = 3;
681};
682} // namespace impl
683} // namespace nvinfer1
684
690extern "C" TENSORRTAPI int32_t getInferLibVersion() noexcept;
691
692#endif // NV_INFER_RUNTIME_BASE_H
#define TENSORRTAPI
Definition: NvInferRuntimeBase.h:70
TENSORRTAPI int32_t getInferLibVersion() noexcept
Return the library version number.
Definition: NvInferRuntimeBase.h:222
static constexpr int32_t MAX_DIMS
The maximum rank (number of dimensions) supported for a tensor.
Definition: NvInferRuntimeBase.h:225
int64_t d[MAX_DIMS]
The extent of each dimension.
Definition: NvInferRuntimeBase.h:231
int32_t nbDims
The rank (number of dimensions).
Definition: NvInferRuntimeBase.h:228
An Interface class for version control.
Definition: NvInferRuntimeBase.h:282
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:289
Version information associated with a TRT interface.
Definition: NvInferRuntimeBase.h:247
InterfaceKind kind
Definition: NvInferRuntimeBase.h:249
int32_t major
Definition: NvInferRuntimeBase.h:250
int32_t minor
Definition: NvInferRuntimeBase.h:251
Definition: NvInferRuntimeBase.h:419
char const * ErrorDesc
A typedef of a C-style string for reporting error descriptions.
Definition: NvInferRuntimeBase.h:432
~IErrorRecorder() noexcept override=default
int32_t RefCount
A typedef of a 32-bit integer for reference counting.
Definition: NvInferRuntimeBase.h:444
InterfaceInfo getInterfaceInfo() const noexcept override
Return version information associated with this interface. Applications must not override this method...
Definition: NvInferRuntimeBase.h:424
Application-implemented logging interface for the builder, refitter and runtime.
Definition: NvInferRuntime.h:1575
The TensorRT API version 1 namespace.
Definition: NvInferSafePlugin.h:33
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeBase.h:315
TensorIOMode
Definition of tensor IO Mode.
Definition: NvInferRuntimeBase.h:662
@ kOUTPUT
Tensor is output by the engine.
@ kINPUT
Tensor is input to the engine.
APILanguage
Programming language used in the implementation of a TRT interface.
Definition: NvInferRuntimeBase.h:260
v_1_0::ILogger ILogger
Definition: NvInferRuntimeBase.h:125
char_t AsciiChar
Definition: NvInferRuntimeBase.h:116
char char_t
char_t is the type used by TensorRT to represent all valid characters.
Definition: NvInferRuntimeBase.h:112
DataType
The type of weights and tensors. The datatypes other than kBOOL, kINT32, and kINT64 are "activation d...
Definition: NvInferRuntimeBase.h:149
@ 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:239
constexpr int32_t EnumMax() noexcept
Definition: NvInferRuntimeBase.h:137
v_1_0::IErrorRecorder IErrorRecorder
Definition: NvInferRuntimeBase.h:124
Declaration of EnumMaxImpl struct to store the exclusive upper bound of an enumeration type.
Definition: NvInferRuntimeBase.h:131

  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