codekingpro/portable-devtools
115k
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
49//! A stand-in for `[[nodiscard]]` and `[[nodiscard(REASON)]]` that works with older compilers.
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
73//!
74//! \file NvInferRuntimeBase.h
75//!
76//! This file contains common definitions, data structures and interfaces shared between the standard and safe runtime.
77//!
78//! \warning Do not directly include this file. Instead include one of:
79//! * NvInferRuntime.h (for the standard runtime)
80//! * NvInferPluginUtils.h (for plugin utilities)
81//!
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
86//! Forward declare some CUDA types to avoid an include dependency.
87
88extern "C"
89{
90 //! Forward declaration of cublasContext to use in other interfaces.
91 struct cublasContext;
92 //! Forward declaration of cudnnContext to use in other interfaces.
93 struct cudnnContext;
94}
95
96//! Construct a single integer denoting TensorRT version.
97//! Usable in preprocessor expressions.
98#define NV_TENSORRT_VERSION_INT(major, minor, patch) ((major) *10000L + (minor) *100L + (patch) *1L)
99
100//! TensorRT version as a single integer.
101//! Usable in preprocessor expressions.
102#define NV_TENSORRT_VERSION NV_TENSORRT_VERSION_INT(NV_TENSORRT_MAJOR, NV_TENSORRT_MINOR, NV_TENSORRT_PATCH)
103
104//!
105//! \namespace nvinfer1
106//!
107//! \brief The TensorRT API version 1 namespace.
108//!
109namespace nvinfer1
110{
111//! char_t is the type used by TensorRT to represent all valid characters.
112using char_t = char;
113
114//! AsciiChar is the type used by TensorRT to represent valid ASCII characters.
115//! This type is widely used in automotive safety context.
116using AsciiChar = char_t;
117
118//! Forward declare IErrorRecorder for use in other interfaces.
119namespace v_1_0
120{
121class IErrorRecorder;
122} // namespace v_1_0
123using IErrorRecorder = v_1_0::IErrorRecorder;
124
125namespace impl
126{
127//! Declaration of EnumMaxImpl struct to store maximum number of elements in an enumeration type.
128template <typename T>
129struct EnumMaxImpl;
130} // namespace impl
131
132//! Maximum number of elements in an enumeration type.
133template <typename T>
134constexpr int32_t EnumMax() noexcept
135{
136 return impl::EnumMaxImpl<T>::kVALUE;
137}
138
139//!
140//! \enum DataType
141//! \brief The type of weights and tensors.
142//! The datatypes other than kBOOL, kINT32, and kINT64 are "activation datatypes,"
143//! as they often represent values corresponding to inference results.
144//!
145enum class DataType : int32_t
146{
147 //! 32-bit floating point format.
148 kFLOAT = 0,
149
150 //! IEEE 16-bit floating-point format -- has a 5 bit exponent and 11 bit significand.
151 kHALF = 1,
152
153 //! Signed 8-bit integer representing a quantized floating-point value.
154 kINT8 = 2,
155
156 //! Signed 32-bit integer format.
157 kINT32 = 3,
158
159 //! 8-bit boolean. 0 = false, 1 = true, other values undefined.
160 kBOOL = 4,
161
162 //! Unsigned 8-bit integer format.
163 //! Cannot be used to represent quantized floating-point values.
164 //! Use the IdentityLayer to convert kUINT8 network-level inputs to {kFLOAT, kHALF} prior
165 //! to use with other TensorRT layers, or to convert intermediate output
166 //! before kUINT8 network-level outputs from {kFLOAT, kHALF} to kUINT8.
167 //! kUINT8 conversions are only supported for {kFLOAT, kHALF}.
168 //! kUINT8 to {kFLOAT, kHALF} conversion will convert the integer values
169 //! to equivalent floating point values.
170 //! {kFLOAT, kHALF} to kUINT8 conversion will convert the floating point values
171 //! to integer values by truncating towards zero. This conversion has undefined behavior for
172 //! floating point values outside the range [0.0F, 256.0F) after truncation.
173 //! kUINT8 conversions are not supported for {kINT8, kINT32, kBOOL}.
174 kUINT8 = 5,
175
176 //! Signed 8-bit floating point with
177 //! 1 sign bit, 4 exponent bits, 3 mantissa bits, and exponent-bias 7.
178 kFP8 = 6,
179
180 //! Brain float -- has an 8 bit exponent and 8 bit significand.
181 kBF16 = 7,
182
183 //! Signed 64-bit integer type.
184 kINT64 = 8,
185
186 //! Signed 4-bit integer type.
187 kINT4 = 9,
188
189 //! 4-bit floating point type
190 //! 1 bit sign, 2 bit exponent, 1 bit mantissa
191 kFP4 = 10,
192
193 //! Unsigned representation of exponent-only 8-bit floating point type for quantization scales
194 kE8M0 = 11,
195};
196
197namespace impl
198{
199//! Maximum number of elements in DataType enum. \see DataType
200template <>
201struct EnumMaxImpl<DataType>
202{
203 //! Declaration of kVALUE that represents the maximum number of elements in the DataType enum.
204 static constexpr int32_t kVALUE = 12;
205};
206} // namespace impl
207
208//!
209//! \class Dims
210//! \brief Structure to define the dimensions of a tensor.
211//!
212//! TensorRT can also return an "invalid dims" structure. This structure is
213//! represented by nbDims == -1 and d[i] == 0 for all i.
214//!
215//! TensorRT can also return an "unknown rank" dims structure. This structure is
216//! represented by nbDims == -1 and d[i] == -1 for all i.
217//!
218class Dims64
219{
220public:
221 //! The maximum rank (number of dimensions) supported for a tensor.
222 static constexpr int32_t MAX_DIMS{8};
223
224 //! The rank (number of dimensions).
225 int32_t nbDims;
226
227 //! The extent of each dimension.
228 int64_t d[MAX_DIMS];
229};
230
231//!
232//! Alias for Dims64.
233//!
234using Dims = Dims64;
235
236using InterfaceKind = char const*;
237
238//!
239//! \class InterfaceInfo
240//!
241//! \brief Version information associated with a TRT interface
242//!
243class InterfaceInfo
244{
245public:
246 InterfaceKind kind;
247 int32_t major;
248 int32_t minor;
249};
250
251//!
252//! \enum APILanguage
253//!
254//! \brief Programming language used in the implementation of a TRT interface
255//!
256enum class APILanguage : int32_t
257{
258 kCPP = 0,
259 kPYTHON = 1
260};
261
262namespace impl
263{
264//! Maximum number of elements in APILanguage enum. \see APILanguage
265template <>
266struct EnumMaxImpl<APILanguage>
267{
268 //! Declaration of kVALUE that represents the maximum number of elements in the APILanguage enum.
269 static constexpr int32_t kVALUE = 2;
270};
271} // namespace impl
272
273//!
274//! \class IVersionedInterface
275//!
276//! \brief An Interface class for version control.
277//!
278class IVersionedInterface
279{
280public:
281 //!
282 //! \brief The language used to build the implementation of this Interface.
283 //!
284 //! Applications must not override this method.
285 //!
286 virtual APILanguage getAPILanguage() const noexcept
287 {
288 return APILanguage::kCPP;
289 }
290
291 //!
292 //! \brief Return version information associated with this interface. Applications must not override this method.
293 //!
294 virtual InterfaceInfo getInterfaceInfo() const noexcept = 0;
295
296 virtual ~IVersionedInterface() noexcept = default;
297
298protected:
299 IVersionedInterface() = default;
300 IVersionedInterface(IVersionedInterface const&) = default;
301 IVersionedInterface(IVersionedInterface&&) = default;
302 IVersionedInterface& operator=(IVersionedInterface const&) & = default;
303 IVersionedInterface& operator=(IVersionedInterface&&) & = default;
304};
305
306//!
307//! \enum ErrorCode
308//!
309//! \brief Error codes that can be returned by TensorRT during execution.
310//!
311enum class ErrorCode : int32_t
312{
313 //!
314 //! Execution completed successfully.
315 //!
316 kSUCCESS = 0,
317
318 //!
319 //! An error that does not fall into any other category. This error is included for forward compatibility.
320 //!
321 kUNSPECIFIED_ERROR = 1,
322
323 //!
324 //! A non-recoverable TensorRT error occurred. TensorRT is in an invalid internal state when this error is
325 //! emitted and any further calls to TensorRT will result in undefined behavior.
326 //!
327 kINTERNAL_ERROR = 2,
328
329 //!
330 //! An argument passed to the function is invalid in isolation.
331 //! This is a violation of the API contract.
332 //!
333 kINVALID_ARGUMENT = 3,
334
335 //!
336 //! An error occurred when comparing the state of an argument relative to other arguments. For example, the
337 //! dimensions for concat differ between two tensors outside of the channel dimension. This error is triggered
338 //! when an argument is correct in isolation, but not relative to other arguments. This is to help to distinguish
339 //! from the simple errors from the more complex errors.
340 //! This is a violation of the API contract.
341 //!
342 kINVALID_CONFIG = 4,
343
344 //!
345 //! An error occurred when performing an allocation of memory on the host or the device.
346 //! A memory allocation error is normally fatal, but in the case where the application provided its own memory
347 //! allocation routine, it is possible to increase the pool of available memory and resume execution.
348 //!
349 kFAILED_ALLOCATION = 5,
350
351 //!
352 //! One, or more, of the components that TensorRT relies on did not initialize correctly.
353 //! This is a system setup issue.
354 //!
355 kFAILED_INITIALIZATION = 6,
356
357 //!
358 //! An error occurred during execution that caused TensorRT to end prematurely, either an asynchronous error,
359 //! user cancellation, or other execution errors reported by CUDA/DLA. In a dynamic system, the
360 //! data can be thrown away and the next frame can be processed or execution can be retried.
361 //! This is either an execution error or a memory error.
362 //!
363 kFAILED_EXECUTION = 7,
364
365 //!
366 //! An error occurred during execution that caused the data to become corrupted, but execution finished. Examples
367 //! of this error are NaN squashing or integer overflow. In a dynamic system, the data can be thrown away and the
368 //! next frame can be processed or execution can be retried.
369 //! This is either a data corruption error, an input error, or a range error.
370 //! This is not used in safety but may be used in standard.
371 //!
372 kFAILED_COMPUTATION = 8,
373
374 //!
375 //! TensorRT was put into a bad state by incorrect sequence of function calls. An example of an invalid state is
376 //! specifying a layer to be DLA only without GPU fallback, and that layer is not supported by DLA. This can occur
377 //! in situations where a service is optimistically executing networks for multiple different configurations
378 //! without checking proper error configurations, and instead throwing away bad configurations caught by TensorRT.
379 //! This is a violation of the API contract, but can be recoverable.
380 //!
381 //! Example of a recovery:
382 //! GPU fallback is disabled and conv layer with large filter(63x63) is specified to run on DLA. This will fail due
383 //! to DLA not supporting the large kernel size. This can be recovered by either turning on GPU fallback
384 //! or setting the layer to run on the GPU.
385 //!
386 kINVALID_STATE = 9,
387
388 //!
389 //! An error occurred due to the network not being supported on the device due to constraints of the hardware or
390 //! system. An example is running an unsafe layer in a safety certified context, or a resource requirement for the
391 //! current network is greater than the capabilities of the target device. The network is otherwise correct, but
392 //! the network and hardware combination is problematic. This can be recoverable.
393 //! Examples:
394 //! * Scratch space requests larger than available device memory and can be recovered by increasing allowed
395 //! workspace size.
396 //! * Tensor size exceeds the maximum element count and can be recovered by reducing the maximum batch size.
397 //!
398 kUNSUPPORTED_STATE = 10,
399
400};
401
402namespace impl
403{
404//! Maximum number of elements in ErrorCode enum. \see ErrorCode
405template <>
406struct EnumMaxImpl<ErrorCode>
407{
408 //! Declaration of kVALUE
409 static constexpr int32_t kVALUE = 11;
410};
411} // namespace impl
412
413namespace v_1_0
414{
415class IErrorRecorder : public IVersionedInterface
416{
417public:
418 //!
419 //! \brief Return version information associated with this interface. Applications must not override this method.
420 //!
421 InterfaceInfo getInterfaceInfo() const noexcept override
422 {
423 return InterfaceInfo{"IErrorRecorder", 1, 0};
424 }
425
426 //!
427 //! \brief A typedef of a C-style string for reporting error descriptions.
428 //!
429 using ErrorDesc = char const*;
430
431 //!
432 //! \brief The length limit for an error description in bytes, excluding the '\0' string terminator.
433 //! Only applicable to safe runtime.
434 //! General error recorder implementation can use any size appropriate for the use case.
435 //!
436 static constexpr size_t kMAX_DESC_LENGTH{127U};
437
438 //!
439 //! \brief A typedef of a 32-bit integer for reference counting.
440 //!
441 using RefCount = int32_t;
442
443 IErrorRecorder() = default;
444 ~IErrorRecorder() noexcept override = default;
445
446 // Public API used to retrieve information from the error recorder.
447
448 //!
449 //! \brief Return the number of errors
450 //!
451 //! Determines the number of errors that occurred between the current point in execution
452 //! and the last time that the clear() was executed. Due to the possibility of asynchronous
453 //! errors occurring, a TensorRT API can return correct results, but still register errors
454 //! with the Error Recorder. The value of getNbErrors() must increment by 1 after each reportError()
455 //! call until clear() is called, or the maximum number of errors that can be stored is exceeded.
456 //!
457 //! \return Returns the number of errors detected, or 0 if there are no errors.
458 //! If the upper bound of errors that can be stored is exceeded, the upper bound value must
459 //! be returned.
460 //!
461 //! For example, if the error recorder can store up to 16 error descriptions but reportError() has
462 //! been called 20 times, getNbErrors() must return 16.
463 //!
464 //! \see clear(), hasOverflowed()
465 //!
466 //! \usage
467 //! - Allowed context for the API call
468 //! - Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads
469 //! when multiple execution contexts are used during runtime.
470 //!
471 virtual int32_t getNbErrors() const noexcept = 0;
472
473 //!
474 //! \brief Returns the ErrorCode enumeration.
475 //!
476 //! \param errorIdx A 32-bit integer that indexes into the error array.
477 //!
478 //! The errorIdx specifies what error code from 0 to getNbErrors()-1 that the application
479 //! wants to analyze and return the error code enum.
480 //!
481 //! \return Returns the enum corresponding to errorIdx if errorIdx is in range (between 0 and getNbErrors()-1).
482 //! ErrorCode::kUNSPECIFIED_ERROR must be returned if errorIdx is not in range.
483 //!
484 //! \see getErrorDesc(), ErrorCode
485 //!
486 //! \usage
487 //! - Allowed context for the API call
488 //! - Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads
489 //! when multiple execution contexts are used during runtime.
490 //!
491 virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
492
493 //!
494 //! \brief Returns a null-terminated C-style string description of the error.
495 //!
496 //! \param errorIdx A 32-bit integer that indexes into the error array.
497 //!
498 //! For the error specified by the idx value, return the string description of the error. The
499 //! error string is a null-terminated C-style string. In the safety context there is a
500 //! constant length requirement to remove any dynamic memory allocations and the error message
501 //! will be truncated if it exceeds kMAX_DESC_LENGTH bytes.
502 //! The format of the string is "<EnumAsStr> - <Description>".
503 //!
504 //! \return Returns a string representation of the error along with a description of the error if errorIdx is in
505 //! range (between 0 and getNbErrors()-1). An empty string will be returned if errorIdx is not in range.
506 //!
507 //! \see getErrorCode()
508 //!
509 //! \usage
510 //! - Allowed context for the API call
511 //! - Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads
512 //! when multiple execution contexts are used during runtime.
513 //!
514 virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
515
516 //!
517 //! \brief Determine if the error stack has overflowed.
518 //!
519 //! In the case when the number of errors is large, this function is used to query if one or more
520 //! errors have been dropped due to lack of storage capacity. This is especially important in the
521 //! automotive safety case where the internal error handling mechanisms cannot allocate memory.
522 //!
523 //! \return true if errors have been dropped due to overflowing the error stack.
524 //!
525 //! \usage
526 //! - Allowed context for the API call
527 //! - Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads
528 //! when multiple execution contexts are used during runtime.
529 //!
530 virtual bool hasOverflowed() const noexcept = 0;
531
532 //!
533 //! \brief Clear the error stack on the error recorder.
534 //!
535 //! Removes all the tracked errors by the error recorder. The implementation must guarantee that after
536 //! this function is called, and as long as no error occurs, the next call to getNbErrors will return
537 //! zero and hasOverflowed will return false.
538 //!
539 //! \see getNbErrors(), hasOverflowed()
540 //!
541 //! \usage
542 //! - Allowed context for the API call
543 //! - Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads
544 //! when multiple execution contexts are used during runtime.
545 //!
546 virtual void clear() noexcept = 0;
547
548 // API used by TensorRT to report Error information to the application.
549
550 //!
551 //! \brief Report an error to the error recorder with the corresponding enum and description.
552 //!
553 //! \param val The error code enum that is being reported.
554 //! \param desc The string description of the error, which will be a NULL-terminated string.
555 //! For safety use cases its length is limited to kMAX_DESC_LENGTH bytes
556 //! (excluding the NULL terminator) and descriptions that exceed this limit will be silently truncated.
557 //!
558 //! Report an error to the user that has a given value and human readable description. The function returns false
559 //! if processing can continue, which implies that the reported error is not fatal. This does not guarantee that
560 //! processing continues, but provides a hint to TensorRT.
561 //! The desc C-string data is only valid during the call to reportError and may be immediately deallocated by the
562 //! caller when reportError returns. The implementation must not store the desc pointer in the ErrorRecorder object
563 //! or otherwise access the data from desc after reportError returns.
564 //!
565 //! \return True if the error is determined to be fatal and processing of the current function must end.
566 //!
567 //! \warning If the error recorder's maximum number of storable errors is exceeded, the error description will be
568 //! silently dropped and the value returned by getNbErrors() will not be incremented. However, the return
569 //! value will still signal whether the error must be considered fatal.
570 //!
571 //! \usage
572 //! - Allowed context for the API call
573 //! - Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads
574 //! when multiple execution contexts are used during runtime.
575 //!
576 virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept = 0;
577
578 //!
579 //! \brief Increments the refcount for the current ErrorRecorder.
580 //!
581 //! Increments the reference count for the object by one and returns the current value. This reference count allows
582 //! the application to know that an object inside of TensorRT has taken a reference to the ErrorRecorder. TensorRT
583 //! guarantees that every call to IErrorRecorder::incRefCount() will be paired with a call to
584 //! IErrorRecorder::decRefCount() when the reference is released. It is undefined behavior to destruct the
585 //! ErrorRecorder when incRefCount() has been called without a corresponding decRefCount().
586 //!
587 //! \return The reference counted value after the increment completes.
588 //!
589 //! \usage
590 //! - Allowed context for the API call
591 //! - Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads
592 //! when multiple execution contexts are used during runtime.
593 //!
594 virtual RefCount incRefCount() noexcept = 0;
595
596 //!
597 //! \brief Decrements the refcount for the current ErrorRecorder.
598 //!
599 //! Decrements the reference count for the object by one and returns the current value. This reference count allows
600 //! the application to know that an object inside of TensorRT has taken a reference to the ErrorRecorder. TensorRT
601 //! guarantees that every call to IErrorRecorder::decRefCount() will be preceded by a call to
602 //! IErrorRecorder::incRefCount(). It is undefined behavior to destruct the ErrorRecorder when incRefCount() has been
603 //! called without a corresponding decRefCount().
604 //!
605 //! \return The reference counted value after the decrement completes.
606 //!
607 //! \usage
608 //! - Allowed context for the API call
609 //! - Thread-safe: Yes, this method is required to be thread-safe and may be called from multiple threads
610 //! when multiple execution contexts are used during runtime.
611 //!
612 virtual RefCount decRefCount() noexcept = 0;
613
614protected:
615 // @cond SuppressDoxyWarnings
616 IErrorRecorder(IErrorRecorder const&) = default;
617 IErrorRecorder(IErrorRecorder&&) = default;
618 IErrorRecorder& operator=(IErrorRecorder const&) & = default;
619 IErrorRecorder& operator=(IErrorRecorder&&) & = default;
620 // @endcond
621}; // class IErrorRecorder
622} // namespace v_1_0
623
624//!
625//! \class IErrorRecorder
626//!
627//! \brief Reference counted application-implemented error reporting interface for TensorRT objects.
628//!
629//! The error reporting mechanism is a user-defined object that interacts with the internal state of the object
630//! that it is assigned to in order to determine information about abnormalities in execution. The error recorder
631//! gets both an error enum that is more descriptive than pass/fail and also a string description that gives more
632//! detail on the exact failure modes. In the safety context, the error strings are all limited to 128 bytes
633//! or less in length, including the NULL terminator.
634//!
635//! The ErrorRecorder gets passed along to any class that is created from another class that has an ErrorRecorder
636//! assigned to it. For example, assigning an ErrorRecorder to an IBuilder allows all INetwork's, ILayer's, and
637//! ITensor's to use the same error recorder. For functions that have their own ErrorRecorder accessor functions.
638//! This allows registering a different error recorder or de-registering of the error recorder for that specific
639//! object.
640//!
641//! ErrorRecorder objects that are used in the safety runtime must define an implementation-dependent upper limit
642//! of errors whose information can be stored, and drop errors above this upper limit. The limit must fit in int32_t.
643//! The IErrorRecorder::hasOverflowed() method is used to signal that one or more errors have been dropped.
644//!
645//! The ErrorRecorder object implementation must be thread safe. All locking and synchronization is pushed to the
646//! interface implementation and TensorRT does not hold any synchronization primitives when calling the interface
647//! functions.
648//!
649//! The lifetime of the ErrorRecorder object must exceed the lifetime of all TensorRT objects that use it.
650//!
651using IErrorRecorder = v_1_0::IErrorRecorder;
652
653//!
654//! \enum TensorIOMode
655//!
656//! \brief Definition of tensor IO Mode.
657//!
658enum class TensorIOMode : int32_t
659{
660 //! Tensor is not an input or output.
661 kNONE = 0,
662
663 //! Tensor is input to the engine.
664 kINPUT = 1,
665
666 //! Tensor is output by the engine.
667 kOUTPUT = 2
668};
669
670namespace impl
671{
672//! Maximum number of elements in TensorIOMode enum. \see TensorIOMode
673template <>
674struct EnumMaxImpl<TensorIOMode>
675{
676 // Declaration of kVALUE that represents maximum number of elements in TensorIOMode enum
677 static constexpr int32_t kVALUE = 3;
678};
679} // namespace impl
680} // namespace nvinfer1
681
682//!
683//! \brief Return the library version number.
684//!
685//! The format is as for TENSORRT_VERSION: (MAJOR * 100 + MINOR) * 100 + PATCH
686//!
687extern "C" TENSORRTAPI int32_t getInferLibVersion() noexcept;
688
689#endif // NV_INFER_RUNTIME_BASE_H
690 