|
TensorRT 10.16.1
|
Abstract Interface for a functionally safe graph for executing inference on a built network. More...
#include <NvInferSafeRuntime.h>
Public Member Functions | |
| ITRTGraph (ITRTGraph const &)=delete | |
| ITRTGraph (ITRTGraph &&)=delete | |
| ITRTGraph & | operator= (ITRTGraph const &) &=delete |
| ITRTGraph & | operator= (ITRTGraph &&) &=delete |
| virtual | ~ITRTGraph () noexcept=default |
| A shallow destructor of ITRTGraph. More... | |
| virtual ErrorCode | clone (ITRTGraph *&graph, ISafeRecorder &recorder) noexcept=0 |
| Specialized Graph shallow copy. More... | |
| virtual ErrorCode | getScratchMemorySize (size_t &size) const noexcept=0 |
| This function returns the scratch memory size (in bytes) needed to store all the intermediate tensors for inference. The user could allocate a scratch memory of this size and pass it to TRT via setScratchMemory if not using trtManagedScratch. More... | |
| virtual ErrorCode | getTRTManagedScratch (bool &flag) const noexcept=0 |
| This function returns the trtManagedScratch flag provided in createTRTGraph call. More... | |
| virtual ErrorCode | setScratchMemory (void *memory) noexcept=0 |
| This function sets the scratch memory for the graph. This should only be called if scratch memory is not TRT managed (trtManagedScratch is false). An error will be recorded if called on a graph where trtManagedScratch is true. More... | |
| virtual ErrorCode | getScratchMemory (void *&memory) noexcept=0 |
| This function gets the scratch memory for the graph. This should only be called if scratch memory is not TRT managed (trtManagedScratch is false). An error will be recorded if called on a graph where trtManagedScratch is true. More... | |
| virtual ErrorCode | getNbIOTensors (int64_t &nb) const noexcept=0 |
| This function returns the total number of input and output tensor for the current graph. More... | |
| virtual ErrorCode | getIOTensorName (AsciiChar const *&name, size_t const index) const noexcept=0 |
| This function returns the name of a tensor for a given index. More... | |
| virtual ErrorCode | getIOTensorDescriptor (TensorDescriptor &desc, AsciiChar const *const tensorName) const noexcept=0 |
| This function should return a TensorDescriptor which contains all the information about the tensor based on the name. More... | |
| virtual ErrorCode | getIOTensorDescriptor (TensorDescriptor &desc, int32_t const index) const noexcept=0 |
| This function should return a TensorDescriptor which contains all the information about the tensor based on the index. More... | |
| virtual ErrorCode | setIOTensorAddress (AsciiChar const *const tensorName, TypedArray const &tensor) noexcept=0 |
| This function assigns a user allocated device memory block for an input tensor to the graph based on its name. More... | |
| virtual ErrorCode | setIOTensorAddress (int32_t const index, TypedArray const &tensor) noexcept=0 |
| This function assigns a user allocated device memory block for an input tensor to the graph based on its index. More... | |
| virtual ErrorCode | getIOTensorAddress (AsciiChar const *const tensorName, TypedArray &tensor) noexcept=0 |
| This function gets the memory address for an user provided input tensor to the graph based on its name. More... | |
| virtual ErrorCode | getIOTensorAddress (int32_t const index, TypedArray &tensor) noexcept=0 |
| This function gets the memory address for an user provided input tensor to the graph based on its index. More... | |
| virtual ErrorCode | setInputConsumedEvent (cudaEvent_t event) noexcept=0 |
| This function sets a cudaEvent on the current graph that triggers when the input is consumed. At that point, the input memory can be recycled, i.e. new input for next inference can be loaded. More... | |
| virtual ErrorCode | getInputConsumedEvent (cudaEvent_t &event) const noexcept=0 |
| This function retrieves the cudaEvent on the current graph that triggers when the input is fully consumed. At that point, the input memory can be recycled, i.e. new input for next inference can be loaded. More... | |
| virtual ErrorCode | getErrorBuffer (RuntimeErrorInformation *&buffer) const noexcept=0 |
| This function retrieves the RuntimeErrorInformation (for async error) buffer for the current graph. This buffer includes all the runtime error types such as gather out of bound, silently consumed NaN value etc. More... | |
| virtual ErrorCode | getSafeRecorder (ISafeRecorder *&recorder) const noexcept=0 |
| This function retrieves the ISafeRecorder for the current graph. More... | |
| virtual ErrorCode | getNbIOProfiles (int64_t &nb) const noexcept=0 |
| This function returns the total number of IO tensor profiles for the current graph. More... | |
| virtual ErrorCode | setIOProfile (int64_t profileIndex) noexcept=0 |
| This function selects the active IOProfile for the graph. If this function is not called, the TRTGraph will default to profile 0. Each IOProfile on the graph is mutually exclusive, meaning only one IOProfile can be active at a time. More... | |
| virtual ErrorCode | getIOProfile (int64_t &profileIndex) const noexcept=0 |
| This function retrieves the index of the current active IOProfile for the graph. More... | |
| virtual ErrorCode | getNbAuxStreams (int32_t &nbStreams) const noexcept=0 |
| Return the number of auxiliary streams used by this graph. More... | |
| virtual ErrorCode | setAuxStreams (cudaStream_t *auxStreams, int32_t nbStreams) noexcept=0 |
| Set the auxiliary streams that TensorRT should use to run kernels on. More... | |
| virtual ErrorCode | executeAsync (cudaStream_t stream) noexcept=0 |
| execute one inference of this graph. More... | |
| virtual ErrorCode | sync () noexcept=0 |
| synchronize one inference of this graph. More... | |
Protected Member Functions | |
| ITRTGraph ()=default | |
Abstract Interface for a functionally safe graph for executing inference on a built network.
|
delete |
|
delete |
|
virtualdefaultnoexcept |
A shallow destructor of ITRTGraph.
|
protecteddefault |
|
pure virtualnoexcept |
Specialized Graph shallow copy.
This function constructs a new ITRTGraph which uses a shared pointer to the persistent part of the graph (pointing to the same set of weights) so we do not duplicate the weights anywhere. Clone will automatically allocate a new scratch memory if the scratch memory is trtManaged (trtManagedScratch set to true in createTRTGraph) otherwise user has to call setScratchMemory before calling execute. The cloned graph will be using the same memory allocator as the original graph.
| graph | A reference to an ITRTGraph pointer, that will be initialized after this call. |
| recorder | An ISafeRecorder that records the errors happening during graph initialization and inference. |
|
pure virtualnoexcept |
execute one inference of this graph.
| stream | A CUDA main stream on which the inference kernels will be enqueued. Must be a valid CUDA stream. |
|
pure virtualnoexcept |
This function retrieves the RuntimeErrorInformation (for async error) buffer for the current graph. This buffer includes all the runtime error types such as gather out of bound, silently consumed NaN value etc.
| buffer | retrieved error buffer. |
|
pure virtualnoexcept |
This function retrieves the cudaEvent on the current graph that triggers when the input is fully consumed. At that point, the input memory can be recycled, i.e. new input for next inference can be loaded.
| event | retrieved cuda event |
|
pure virtualnoexcept |
This function retrieves the index of the current active IOProfile for the graph.
| profileIndex | retrieved profile index. |
|
pure virtualnoexcept |
This function gets the memory address for an user provided input tensor to the graph based on its name.
| tensorName | the tensor name that the user would like to obtain memory for. |
| tensor | set to a device memory pointer allocated by user for the tensor. |
|
pure virtualnoexcept |
This function gets the memory address for an user provided input tensor to the graph based on its index.
| index | the tensor index that the user would like to obtain memory for. |
| tensor | set to a device memory pointer allocated by user for the tensor. |
|
pure virtualnoexcept |
This function should return a TensorDescriptor which contains all the information about the tensor based on the name.
| desc | corresponding TensorDescriptor that will be filled out after the call. |
| name | name of the tensor we are interested in. |
|
pure virtualnoexcept |
This function should return a TensorDescriptor which contains all the information about the tensor based on the index.
| desc | corresponding TensorDescriptor that will be filled out after the call. |
| index | index of the tensor we are interested in (starting from 0). |
|
pure virtualnoexcept |
This function returns the name of a tensor for a given index.
| name | The name string of the tensor that will be filled out after the call. |
| index | The index of the tensor whose name is to be returned. |
|
pure virtualnoexcept |
Return the number of auxiliary streams used by this graph.
| nbStreams | The return value for the number of auxiliary streams. |
|
pure virtualnoexcept |
This function returns the total number of IO tensor profiles for the current graph.
| nb | The return value for the total number of IO tensor profiles for the current graph. A graph will at least have 1 IOProfile |
|
pure virtualnoexcept |
This function returns the total number of input and output tensor for the current graph.
| nb | The return value for total number of input and output tensor for the current graph. |
|
pure virtualnoexcept |
This function retrieves the ISafeRecorder for the current graph.
| recorder | retrieved ISafeRecorder. |
|
pure virtualnoexcept |
This function gets the scratch memory for the graph. This should only be called if scratch memory is not TRT managed (trtManagedScratch is false). An error will be recorded if called on a graph where trtManagedScratch is true.
| memory | set to a device memory pointer allocated by user or nullptr when the scratch memory is TRT managed. |
|
pure virtualnoexcept |
This function returns the scratch memory size (in bytes) needed to store all the intermediate tensors for inference. The user could allocate a scratch memory of this size and pass it to TRT via setScratchMemory if not using trtManagedScratch.
| size | The return value for the scratch memory size (in bytes) needed to store all the intermediate tensors for inference. |
|
pure virtualnoexcept |
This function returns the trtManagedScratch flag provided in createTRTGraph call.
| flag | A boolean flag that determines if scratch memory is managed by TRT |
|
pure virtualnoexcept |
Set the auxiliary streams that TensorRT should use to run kernels on.
TRT will launch the kernels that are supposed to run on the auxiliary streams using the streams provided by the user via this API. The user is responsible for allocating and deallocating these streams.
If getNbAuxStreams() returns a value greater than 0, this API must be called before executeAsync() to provide the required auxiliary streams.
If getNbAuxStreams() returns 0, setAuxStreams() can only be called with an array of size 0.
| auxStreams | The pointer to an array of cudaStream_t with the array length equal to nbStreams. All streams in the array must be valid CUDA streams. |
| nbStreams | The number of auxiliary streams provided. Must be equal to the value returned by getNbAuxStreams(). If nbStreams does not match, kINVALID_ARGUMENT will be returned. |
|
pure virtualnoexcept |
This function sets a cudaEvent on the current graph that triggers when the input is consumed. At that point, the input memory can be recycled, i.e. new input for next inference can be loaded.
| event | cuda event to be set |
|
pure virtualnoexcept |
This function selects the active IOProfile for the graph. If this function is not called, the TRTGraph will default to profile 0. Each IOProfile on the graph is mutually exclusive, meaning only one IOProfile can be active at a time.
| profileIndex | The index of the profile to select. |
|
pure virtualnoexcept |
This function assigns a user allocated device memory block for an input tensor to the graph based on its name.
| tensorName | the tensor name that the user would like to provide memory for. |
| tensor | a device memory block allocated by user for the tensor. |
|
pure virtualnoexcept |
This function assigns a user allocated device memory block for an input tensor to the graph based on its index.
| index | the tensor index that the user would like to provide memory for. |
| tensor | a device memory block allocated by user for the tensor. |
|
pure virtualnoexcept |
This function sets the scratch memory for the graph. This should only be called if scratch memory is not TRT managed (trtManagedScratch is false). An error will be recorded if called on a graph where trtManagedScratch is true.
| memory | pointer to a device memory block allocated by user that is at least as large as getScratchMemorySize, or nullptr which will reset the internal pointer. |
|
pure virtualnoexcept |
synchronize one inference of this graph.
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