TensorRT 10.8.0
NvInferRuntimeBase.h
前往此文件的文档。
1/*
2 * SPDX-FileCopyrightText: 版权所有 (c) 1993-2024 NVIDIA CORPORATION & AFFILIATES。保留所有权利。
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * 根据 Apache 许可证 2.0 版(“许可证”)获得许可;
6 * 除非符合许可证,否则您不得使用此文件。
7 * 您可以在以下位置获取许可证副本:
8 *
9 * https://apache.ac.cn/licenses/LICENSE-2.0
10 *
11 * 除非适用法律要求或以书面形式达成协议,否则
12 * 根据许可证分发的软件按“现状”基础分发,
13 * 不附带任何形式的明示或暗示的保证或条件。
14 * 有关管理权限和限制的特定语言,请参阅许可证。
15 * 许可证下的限制。
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// 标记为已弃用的项目将在未来的版本中移除。
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// 定义哪些符号被导出
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, "不要直接包含此文件。请包含 NvInferRuntime.h 或 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
413using ErrorDesc = char const*;
414
420static constexpr size_t kMAX_DESC_LENGTH{127U};
421
425using RefCount = int32_t;
426
427IErrorRecorder() = default;
428~IErrorRecorder() noexcept override = default;
429
430 // 用于从错误记录器检索信息的公共 API。
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 // TensorRT 用于向应用程序报告错误信息的 API。
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 // TensorIOMode 枚举中表示最大元素数量的 kVALUE 声明
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
返回库版本号。
Definition: NvInferRuntimeBase.h:203
static constexpr int32_t MAX_DIMS
张量支持的最大秩(维度数量)。
Definition: NvInferRuntimeBase.h:206
int64_t d[MAX_DIMS]
每个维度的范围。
Definition: NvInferRuntimeBase.h:212
int32_t nbDims
秩(维度数量)。
Definition: NvInferRuntimeBase.h:209
用于版本控制的接口类。
Definition: NvInferRuntimeBase.h:263
virtual InterfaceInfo getInterfaceInfo() const noexcept=0
返回与此接口关联的版本信息。应用程序不得覆盖此方法...
virtual APILanguage getAPILanguage() const noexcept
用于构建此接口实现的语言。
Definition: NvInferRuntimeBase.h:270
与 TRT 接口关联的版本信息。
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
用于报告错误描述的 C 风格字符串的 typedef。
Definition: NvInferRuntimeBase.h:413
~IErrorRecorder() noexcept override=default
int32_t RefCount
用于引用计数的 32 位整数的 typedef。
Definition: NvInferRuntimeBase.h:425
InterfaceInfo getInterfaceInfo() const noexcept override
返回与此接口关联的版本信息。应用程序不得覆盖此方法...
定义: NvInferRuntimeBase.h:405
TensorRT API 版本 1 的命名空间。
ErrorCode
TensorRT 在执行期间可能返回的错误代码。
定义: NvInferRuntimeBase.h:296
TensorIOMode
张量 IO 模式的定义。
定义: NvInferRuntimeBase.h:643
@ kOUTPUT
张量由引擎输出。
@ kINPUT
张量是引擎的输入。
APILanguage
在 TRT 接口实现中使用的编程语言。
定义: NvInferRuntimeBase.h:241
char_t AsciiChar
定义: NvInferRuntimeBase.h:105
char char_t
char_t 是 TensorRT 用于表示所有有效字符的类型。
定义: NvInferRuntimeBase.h:101
DataType
权重和张量的类型。
定义: NvInferRuntimeBase.h:133
@ kINT64
有符号 64 位整数类型。
@ kFLOAT
32 位浮点格式。
@ kBOOL
8 位布尔值。0 = false,1 = true,其他值未定义。
@ kHALF
IEEE 16 位浮点格式 – 具有 5 位指数和 11 位尾数。
@ kINT8
有符号 8 位整数,表示量化的浮点值。
@ kBF16
Brain float – 具有 8 位指数和 8 位尾数。
@ kINT4
有符号 4 位整数类型。
@ kINT32
有符号 32 位整数格式。
char const * InterfaceKind
定义: NvInferRuntimeBase.h:220
constexpr int32_t EnumMax() noexcept
枚举类型中元素的最大数量。
定义: NvInferRuntimeBase.h:123
v_1_0::IErrorRecorder IErrorRecorder
定义: NvInferRuntimeBase.h:112
EnumMaxImpl 结构的声明,用于存储枚举类型中元素的最大数量。
定义: NvInferRuntimeBase.h:118

  版权所有 © 2024 NVIDIA Corporation
  Privacy Policy | Manage My Privacy | Do Not Sell or Share My Data | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact