TensorRT for RTX 1.2.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_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#define TENSORRTAPI __declspec(dllexport)
65#else
66#define TENSORRTAPI __attribute__((visibility("default")))
67#endif
68#else
69#define TENSORRTAPI
70#endif
71#define TRTNOEXCEPT
81#if !defined(NV_INFER_INTERNAL_INCLUDE)
82static_assert(false, "Do not directly include this file. Include NvInferRuntime.h or NvInferPluginUtils.h");
83#endif
84
86
87extern "C"
88{
90 struct cublasContext;
92 struct cudnnContext;
93}
94
97#define NV_TENSORRT_VERSION_INT(major, minor, patch) ((major) *10000L + (minor) *100L + (patch) *1L)
98
101#define NV_TENSORRT_VERSION NV_TENSORRT_VERSION_INT(NV_TENSORRT_MAJOR, NV_TENSORRT_MINOR, NV_TENSORRT_PATCH)
102
108namespace nvinfer1
109{
111using char_t = char;
112
116
118namespace v_1_0
119{
120class IErrorRecorder;
121} // namespace v_1_0
123
124namespace impl
125{
127template <typename T>
129} // namespace impl
130
132template <typename T>
133constexpr int32_t EnumMax() noexcept
134{
136}
137
144enum class DataType : int32_t
145{
147 kFLOAT = 0,
148
150 kHALF = 1,
151
153 kINT8 = 2,
154
156 kINT32 = 3,
157
159 kBOOL = 4,
160
173 kUINT8 = 5,
174
177 kFP8 = 6,
178
180 kBF16 = 7,
181
183 kINT64 = 8,
184
186 kINT4 = 9,
187
190 kFP4 = 10,
191
193 kE8M0 = 11,
194};
195
196namespace impl
197{
199template <>
201{
203 static constexpr int32_t kVALUE = 12;
204};
205} // namespace impl
206
218{
219public:
221 static constexpr int32_t MAX_DIMS{8};
222
224 int32_t nbDims;
225
227 int64_t d[MAX_DIMS];
228};
229
233using Dims = Dims64;
234
235using InterfaceKind = char const*;
236
243{
244public:
246 int32_t major;
247 int32_t minor;
248};
249
255enum class APILanguage : int32_t
256{
257 kCPP = 0,
258 kPYTHON = 1
259};
260
261namespace impl
262{
264template <>
266{
268 static constexpr int32_t kVALUE = 2;
269};
270} // namespace impl
271
278{
279public:
285 virtual APILanguage getAPILanguage() const noexcept
286 {
287 return APILanguage::kCPP;
288 }
289
293 virtual InterfaceInfo getInterfaceInfo() const noexcept = 0;
294
295 virtual ~IVersionedInterface() noexcept = default;
296
297protected:
301 IVersionedInterface& operator=(IVersionedInterface const&) & = default;
302 IVersionedInterface& operator=(IVersionedInterface&&) & = default;
303};
304
310enum class ErrorCode : int32_t
311{
315 kSUCCESS = 0,
316
321
326 kINTERNAL_ERROR = 2,
327
333
341 kINVALID_CONFIG = 4,
342
349
355
363
372
385 kINVALID_STATE = 9,
386
398
399};
400
401namespace impl
402{
404template <>
406{
408 static constexpr int32_t kVALUE = 11;
409};
410} // namespace impl
411
412namespace v_1_0
413{
415{
416public:
420 InterfaceInfo getInterfaceInfo() const noexcept override
421 {
422 return InterfaceInfo{"IErrorRecorder", 1, 0};
423 }
424
428 using ErrorDesc = char const*;
429
435 static constexpr size_t kMAX_DESC_LENGTH{127U};
436
440 using RefCount = int32_t;
441
442 IErrorRecorder() = default;
443 ~IErrorRecorder() noexcept override = default;
444
445 // Public API used to retrieve information from the error recorder.
446
470 virtual int32_t getNbErrors() const noexcept = 0;
471
490 virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
491
513 virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
514
529 virtual bool hasOverflowed() const noexcept = 0;
530
545 virtual void clear() noexcept = 0;
546
547 // API used by TensorRT to report Error information to the application.
548
575 virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept = 0;
576
593 virtual RefCount incRefCount() noexcept = 0;
594
611 virtual RefCount decRefCount() noexcept = 0;
612
613protected:
614 // @cond SuppressDoxyWarnings
615 IErrorRecorder(IErrorRecorder const&) = default;
616 IErrorRecorder(IErrorRecorder&&) = default;
617 IErrorRecorder& operator=(IErrorRecorder const&) & = default;
618 IErrorRecorder& operator=(IErrorRecorder&&) & = default;
619 // @endcond
620}; // class IErrorRecorder
621} // namespace v_1_0
622
650using IErrorRecorder = v_1_0::IErrorRecorder;
651
657enum class TensorIOMode : int32_t
658{
660 kNONE = 0,
661
663 kINPUT = 1,
664
666 kOUTPUT = 2
667};
668
669namespace impl
670{
672template <>
674{
675 // Declaration of kVALUE that represents maximum number of elements in TensorIOMode enum
676 static constexpr int32_t kVALUE = 3;
677};
678} // namespace impl
679} // namespace nvinfer1
680
686extern "C" TENSORRTAPI int32_t getInferLibVersion() noexcept;
687
688#endif // NV_INFER_RUNTIME_BASE_H
#define TENSORRTAPI
Definition: NvInferRuntimeBase.h:69
TENSORRTAPI int32_t getInferLibVersion() noexcept
Return the library version number.
Definition: NvInferRuntimeBase.h:218
static constexpr int32_t MAX_DIMS
The maximum rank (number of dimensions) supported for a tensor.
Definition: NvInferRuntimeBase.h:221
int64_t d[MAX_DIMS]
The extent of each dimension.
Definition: NvInferRuntimeBase.h:227
int32_t nbDims
The rank (number of dimensions).
Definition: NvInferRuntimeBase.h:224
An Interface class for version control.
Definition: NvInferRuntimeBase.h:278
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:285
Version information associated with a TRT interface.
Definition: NvInferRuntimeBase.h:243
InterfaceKind kind
Definition: NvInferRuntimeBase.h:245
int32_t major
Definition: NvInferRuntimeBase.h:246
int32_t minor
Definition: NvInferRuntimeBase.h:247
Definition: NvInferRuntimeBase.h:415
char const * ErrorDesc
A typedef of a C-style string for reporting error descriptions.
Definition: NvInferRuntimeBase.h:428
~IErrorRecorder() noexcept override=default
int32_t RefCount
A typedef of a 32-bit integer for reference counting.
Definition: NvInferRuntimeBase.h:440
InterfaceInfo getInterfaceInfo() const noexcept override
Return version information associated with this interface. Applications must not override this method...
Definition: NvInferRuntimeBase.h:420
The TensorRT-RTX API version 1 namespace.
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeBase.h:311
TensorIOMode
Definition of tensor IO Mode.
Definition: NvInferRuntimeBase.h:658
@ 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:256
char_t AsciiChar
Definition: NvInferRuntimeBase.h:115
char char_t
char_t is the type used by TensorRT to represent all valid characters.
Definition: NvInferRuntimeBase.h:111
DataType
The type of weights and tensors. The datatypes other than kBOOL, kINT32, and kINT64 are "activation d...
Definition: NvInferRuntimeBase.h:145
@ 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:235
constexpr int32_t EnumMax() noexcept
Maximum number of elements in an enumeration type.
Definition: NvInferRuntimeBase.h:133
v_1_0::IErrorRecorder IErrorRecorder
Definition: NvInferRuntimeBase.h:122
Declaration of EnumMaxImpl struct to store maximum number of elements in an enumeration type.
Definition: NvInferRuntimeBase.h:128

  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