TensorRT 10.8.0
NvInferRuntimeBase.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 1993-2024 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#if __GNUC__ < 6
30#define TRT_DEPRECATED_ENUM
31#else
32#define TRT_DEPRECATED_ENUM TRT_DEPRECATED
33#endif
34#ifdef _MSC_VER
35#define TRT_DEPRECATED_API __declspec(dllexport)
36#else
37#define TRT_DEPRECATED_API [[deprecated]] __attribute__((visibility("default")))
38#endif
39#else
40#ifdef _MSC_VER
41#define TRT_DEPRECATED
42#define TRT_DEPRECATED_ENUM
43#define TRT_DEPRECATED_API __declspec(dllexport)
44#else
45#define TRT_DEPRECATED __attribute__((deprecated))
46#define TRT_DEPRECATED_ENUM
47#define TRT_DEPRECATED_API __attribute__((deprecated, visibility("default")))
48#endif
49#endif
50
51// Defines which symbols are exported
52#ifdef TENSORRT_BUILD_LIB
53#ifdef _MSC_VER
54#define TENSORRTAPI __declspec(dllexport)
55#else
56#define TENSORRTAPI __attribute__((visibility("default")))
57#endif
58#else
59#define TENSORRTAPI
60#endif
61#define TRTNOEXCEPT
71#if !defined(NV_INFER_INTERNAL_INCLUDE)
72static_assert(false, "Do not directly include this file. Include NvInferRuntime.h or NvInferPluginUtils.h");
73#endif
74
76
77extern "C"
78{
80 struct cublasContext;
82 struct cudnnContext;
83}
84
87#define NV_TENSORRT_VERSION_INT(major, minor, patch) ((major) *10000L + (minor) *100L + (patch) *1L)
88
91#define NV_TENSORRT_VERSION NV_TENSORRT_VERSION_INT(NV_TENSORRT_MAJOR, NV_TENSORRT_MINOR, NV_TENSORRT_PATCH)
92
98namespace nvinfer1
99{
101using char_t = char;
102
106
108namespace v_1_0
109{
110class IErrorRecorder;
111}
113
114namespace impl
115{
117template <typename T>
119} // namespace impl
120
122template <typename T>
123constexpr int32_t EnumMax() noexcept
124{
126}
127
132enum class DataType : int32_t
133{
135 kFLOAT = 0,
136
138 kHALF = 1,
139
141 kINT8 = 2,
142
144 kINT32 = 3,
145
147 kBOOL = 4,
148
161 kUINT8 = 5,
162
165 kFP8 = 6,
166
168 kBF16 = 7,
169
171 kINT64 = 8,
172
174 kINT4 = 9,
175
178 kFP4 = 10,
179};
180
181namespace impl
182{
184template <>
186{
188 static constexpr int32_t kVALUE = 11;
189};
190} // namespace impl
191
203{
204public:
206 static constexpr int32_t MAX_DIMS{8};
207
209 int32_t nbDims;
210
212 int64_t d[MAX_DIMS];
213};
214
218using Dims = Dims64;
219
220using InterfaceKind = char const*;
221
228{
229public:
231 int32_t major;
232 int32_t minor;
233};
234
240enum class APILanguage : int32_t
241{
242 kCPP = 0,
243 kPYTHON = 1
244};
245
246namespace impl
247{
249template <>
251{
253 static constexpr int32_t kVALUE = 2;
254};
255} // namespace impl
256
263{
264public:
270 virtual APILanguage getAPILanguage() const noexcept
271 {
272 return APILanguage::kCPP;
273 }
274
278 virtual InterfaceInfo getInterfaceInfo() const noexcept = 0;
279
280 virtual ~IVersionedInterface() noexcept = default;
281
282protected:
286 IVersionedInterface& operator=(IVersionedInterface const&) & = default;
287 IVersionedInterface& operator=(IVersionedInterface&&) & = default;
288};
289
295enum class ErrorCode : int32_t
296{
300 kSUCCESS = 0,
301
306
311 kINTERNAL_ERROR = 2,
312
318
326 kINVALID_CONFIG = 4,
327
334
340
348
357
370 kINVALID_STATE = 9,
371
383
384};
385
386namespace impl
387{
389template <>
391{
393 static constexpr int32_t kVALUE = 11;
394};
395} // namespace impl
396
397namespace v_1_0
398{
400{
401public:
405 InterfaceInfo getInterfaceInfo() const noexcept override
406 {
407 return InterfaceInfo{"IErrorRecorder", 1, 0};
408 }
409
413 using ErrorDesc = char const*;
414
420 static constexpr size_t kMAX_DESC_LENGTH{127U};
421
425 using RefCount = int32_t;
426
427 IErrorRecorder() = default;
428 ~IErrorRecorder() noexcept override = default;
429
430 // Public API used to retrieve information from the error recorder.
431
455 virtual int32_t getNbErrors() const noexcept = 0;
456
475 virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
476
498 virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
499
514 virtual bool hasOverflowed() const noexcept = 0;
515
530 virtual void clear() noexcept = 0;
531
532 // API used by TensorRT to report Error information to the application.
533
560 virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept = 0;
561
578 virtual RefCount incRefCount() noexcept = 0;
579
596 virtual RefCount decRefCount() noexcept = 0;
597
598protected:
599 // @cond SuppressDoxyWarnings
600 IErrorRecorder(IErrorRecorder const&) = default;
601 IErrorRecorder(IErrorRecorder&&) = default;
602 IErrorRecorder& operator=(IErrorRecorder const&) & = default;
603 IErrorRecorder& operator=(IErrorRecorder&&) & = default;
604 // @endcond
605}; // class IErrorRecorder
606} // namespace v_1_0
607
635using IErrorRecorder = v_1_0::IErrorRecorder;
636
642enum class TensorIOMode : int32_t
643{
645 kNONE = 0,
646
648 kINPUT = 1,
649
651 kOUTPUT = 2
652};
653
654namespace impl
655{
657template <>
659{
660 // Declaration of kVALUE that represents maximum number of elements in TensorIOMode enum
661 static constexpr int32_t kVALUE = 3;
662};
663} // namespace impl
664} // namespace nvinfer1
665
671extern "C" TENSORRTAPI int32_t getInferLibVersion() noexcept;
672
673#endif // NV_INFER_RUNTIME_BASE_H
#define TENSORRTAPI
Definition: NvInferRuntimeBase.h:59
int32_t getInferLibVersion() noexcept
Return the library version number.
Definition: NvInferRuntimeBase.h:203
static constexpr int32_t MAX_DIMS
The maximum rank (number of dimensions) supported for a tensor.
Definition: NvInferRuntimeBase.h:206
int64_t d[MAX_DIMS]
The extent of each dimension.
Definition: NvInferRuntimeBase.h:212
int32_t nbDims
The rank (number of dimensions).
Definition: NvInferRuntimeBase.h:209
An Interface class for version control.
Definition: NvInferRuntimeBase.h:263
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:270
Version information associated with a TRT interface.
Definition: NvInferRuntimeBase.h:228
InterfaceKind kind
Definition: NvInferRuntimeBase.h:230
int32_t major
Definition: NvInferRuntimeBase.h:231
int32_t minor
Definition: NvInferRuntimeBase.h:232
Definition: NvInferRuntimeBase.h:400
char const * ErrorDesc
A typedef of a C-style string for reporting error descriptions.
Definition: NvInferRuntimeBase.h:413
~IErrorRecorder() noexcept override=default
int32_t RefCount
A typedef of a 32-bit integer for reference counting.
Definition: NvInferRuntimeBase.h:425
InterfaceInfo getInterfaceInfo() const noexcept override
Return version information associated with this interface. Applications must not override this method...
Definition: NvInferRuntimeBase.h:405
The TensorRT API version 1 namespace.
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeBase.h:296
TensorIOMode
Definition of tensor IO Mode.
Definition: NvInferRuntimeBase.h:643
@ 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:241
char_t AsciiChar
Definition: NvInferRuntimeBase.h:105
char char_t
char_t is the type used by TensorRT to represent all valid characters.
Definition: NvInferRuntimeBase.h:101
DataType
The type of weights and tensors.
Definition: NvInferRuntimeBase.h:133
@ 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:220
constexpr int32_t EnumMax() noexcept
Maximum number of elements in an enumeration type.
Definition: NvInferRuntimeBase.h:123
v_1_0::IErrorRecorder IErrorRecorder
Definition: NvInferRuntimeBase.h:112
Declaration of EnumMaxImpl struct to store maximum number of elements in an enumeration type.
Definition: NvInferRuntimeBase.h:118

  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