TensorRT 10.10.0
NvInferRuntimeBase.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 1993-2025 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_ENUM TRT_DEPRECATED
30#ifdef _MSC_VER
31#define TRT_DEPRECATED_API __declspec(dllexport)
32#else
33#define TRT_DEPRECATED_API [[deprecated]] __attribute__((visibility("default")))
34#endif
35#else
36#ifdef _MSC_VER
37#define TRT_DEPRECATED
38#define TRT_DEPRECATED_ENUM
39#define TRT_DEPRECATED_API __declspec(dllexport)
40#else
41#define TRT_DEPRECATED __attribute__((deprecated))
42#define TRT_DEPRECATED_ENUM
43#define TRT_DEPRECATED_API __attribute__((deprecated, visibility("default")))
44#endif
45#endif
46
47// Defines which symbols are exported
48#ifdef TENSORRT_BUILD_LIB
49#ifdef _MSC_VER
50#define TENSORRTAPI __declspec(dllexport)
51#else
52#define TENSORRTAPI __attribute__((visibility("default")))
53#endif
54#else
55#define TENSORRTAPI
56#endif
57#define TRTNOEXCEPT
67#if !defined(NV_INFER_INTERNAL_INCLUDE)
68static_assert(false, "Do not directly include this file. Include NvInferRuntime.h or NvInferPluginUtils.h");
69#endif
70
72
73extern "C"
74{
76 struct cublasContext;
78 struct cudnnContext;
79}
80
83#define NV_TENSORRT_VERSION_INT(major, minor, patch) ((major) *10000L + (minor) *100L + (patch) *1L)
84
87#define NV_TENSORRT_VERSION NV_TENSORRT_VERSION_INT(NV_TENSORRT_MAJOR, NV_TENSORRT_MINOR, NV_TENSORRT_PATCH)
88
94namespace nvinfer1
95{
97using char_t = char;
98
102
104namespace v_1_0
105{
106class IErrorRecorder;
107}
109
110namespace impl
111{
113template <typename T>
115} // namespace impl
116
118template <typename T>
119constexpr int32_t EnumMax() noexcept
120{
122}
123
128enum class DataType : int32_t
129{
131 kFLOAT = 0,
132
134 kHALF = 1,
135
137 kINT8 = 2,
138
140 kINT32 = 3,
141
143 kBOOL = 4,
144
157 kUINT8 = 5,
158
161 kFP8 = 6,
162
164 kBF16 = 7,
165
167 kINT64 = 8,
168
170 kINT4 = 9,
171
174 kFP4 = 10,
175
176};
177
178namespace impl
179{
181template <>
183{
185 static constexpr int32_t kVALUE = 11;
186};
187} // namespace impl
188
200{
201public:
203 static constexpr int32_t MAX_DIMS{8};
204
206 int32_t nbDims;
207
209 int64_t d[MAX_DIMS];
210};
211
215using Dims = Dims64;
216
217using InterfaceKind = char const*;
218
225{
226public:
228 int32_t major;
229 int32_t minor;
230};
231
237enum class APILanguage : int32_t
238{
239 kCPP = 0,
240 kPYTHON = 1
241};
242
243namespace impl
244{
246template <>
248{
250 static constexpr int32_t kVALUE = 2;
251};
252} // namespace impl
253
260{
261public:
267 virtual APILanguage getAPILanguage() const noexcept
268 {
269 return APILanguage::kCPP;
270 }
271
275 virtual InterfaceInfo getInterfaceInfo() const noexcept = 0;
276
277 virtual ~IVersionedInterface() noexcept = default;
278
279protected:
283 IVersionedInterface& operator=(IVersionedInterface const&) & = default;
284 IVersionedInterface& operator=(IVersionedInterface&&) & = default;
285};
286
292enum class ErrorCode : int32_t
293{
297 kSUCCESS = 0,
298
303
308 kINTERNAL_ERROR = 2,
309
315
323 kINVALID_CONFIG = 4,
324
331
337
345
354
367 kINVALID_STATE = 9,
368
380
381};
382
383namespace impl
384{
386template <>
388{
390 static constexpr int32_t kVALUE = 11;
391};
392} // namespace impl
393
394namespace v_1_0
395{
397{
398public:
402 InterfaceInfo getInterfaceInfo() const noexcept override
403 {
404 return InterfaceInfo{"IErrorRecorder", 1, 0};
405 }
406
410 using ErrorDesc = char const*;
411
417 static constexpr size_t kMAX_DESC_LENGTH{127U};
418
422 using RefCount = int32_t;
423
424 IErrorRecorder() = default;
425 ~IErrorRecorder() noexcept override = default;
426
427 // Public API used to retrieve information from the error recorder.
428
452 virtual int32_t getNbErrors() const noexcept = 0;
453
472 virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
473
495 virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
496
511 virtual bool hasOverflowed() const noexcept = 0;
512
527 virtual void clear() noexcept = 0;
528
529 // API used by TensorRT to report Error information to the application.
530
557 virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept = 0;
558
575 virtual RefCount incRefCount() noexcept = 0;
576
593 virtual RefCount decRefCount() noexcept = 0;
594
595protected:
596 // @cond SuppressDoxyWarnings
597 IErrorRecorder(IErrorRecorder const&) = default;
598 IErrorRecorder(IErrorRecorder&&) = default;
599 IErrorRecorder& operator=(IErrorRecorder const&) & = default;
600 IErrorRecorder& operator=(IErrorRecorder&&) & = default;
601 // @endcond
602}; // class IErrorRecorder
603} // namespace v_1_0
604
632using IErrorRecorder = v_1_0::IErrorRecorder;
633
639enum class TensorIOMode : int32_t
640{
642 kNONE = 0,
643
645 kINPUT = 1,
646
648 kOUTPUT = 2
649};
650
651namespace impl
652{
654template <>
656{
657 // Declaration of kVALUE that represents maximum number of elements in TensorIOMode enum
658 static constexpr int32_t kVALUE = 3;
659};
660} // namespace impl
661} // namespace nvinfer1
662
668extern "C" TENSORRTAPI int32_t getInferLibVersion() noexcept;
669
670#endif // NV_INFER_RUNTIME_BASE_H
#define TENSORRTAPI
Definition: NvInferRuntimeBase.h:55
int32_t getInferLibVersion() noexcept
Return the library version number.
Definition: NvInferRuntimeBase.h:200
static constexpr int32_t MAX_DIMS
The maximum rank (number of dimensions) supported for a tensor.
Definition: NvInferRuntimeBase.h:203
int64_t d[MAX_DIMS]
The extent of each dimension.
Definition: NvInferRuntimeBase.h:209
int32_t nbDims
The rank (number of dimensions).
Definition: NvInferRuntimeBase.h:206
An Interface class for version control.
Definition: NvInferRuntimeBase.h:260
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:267
Version information associated with a TRT interface.
Definition: NvInferRuntimeBase.h:225
InterfaceKind kind
Definition: NvInferRuntimeBase.h:227
int32_t major
Definition: NvInferRuntimeBase.h:228
int32_t minor
Definition: NvInferRuntimeBase.h:229
Definition: NvInferRuntimeBase.h:397
char const * ErrorDesc
A typedef of a C-style string for reporting error descriptions.
Definition: NvInferRuntimeBase.h:410
~IErrorRecorder() noexcept override=default
int32_t RefCount
A typedef of a 32-bit integer for reference counting.
Definition: NvInferRuntimeBase.h:422
InterfaceInfo getInterfaceInfo() const noexcept override
Return version information associated with this interface. Applications must not override this method...
Definition: NvInferRuntimeBase.h:402
The TensorRT API version 1 namespace.
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeBase.h:293
TensorIOMode
Definition of tensor IO Mode.
Definition: NvInferRuntimeBase.h:640
@ 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:238
char_t AsciiChar
Definition: NvInferRuntimeBase.h:101
char char_t
char_t is the type used by TensorRT to represent all valid characters.
Definition: NvInferRuntimeBase.h:97
DataType
The type of weights and tensors.
Definition: NvInferRuntimeBase.h:129
@ 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.
@ 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:217
constexpr int32_t EnumMax() noexcept
Maximum number of elements in an enumeration type.
Definition: NvInferRuntimeBase.h:119
v_1_0::IErrorRecorder IErrorRecorder
Definition: NvInferRuntimeBase.h:108
Declaration of EnumMaxImpl struct to store maximum number of elements in an enumeration type.
Definition: NvInferRuntimeBase.h:114

  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