[BYOC][TRT] Allocate GPU data buffers and transfer data when needed - #6872
Merged
Merged
Conversation
Contributor
Author
comaniac
requested changes
Nov 7, 2020
| #ifdef TVM_GRAPH_RUNTIME_TENSORRT | ||
| /*! \brief Run inference using built engine. */ | ||
| void Run() override { | ||
| BuildEngine(); |
Contributor
There was a problem hiding this comment.
Is the reason of moving BuildEngine from Init to Run because you need subgraph specific information (e.g., I/O data entry IDs) to allocate device buffers?
Contributor
Author
There was a problem hiding this comment.
Thanks @comaniac for the review! Yes, to allocate the device buffers we need the DLTensor context and shape. data_entry_ in JSON runtime isn't initialized until Run() so I had to move BuildEngine.
In the future, we are planning to be able to dynamically build engines for different input shapes in order to handle subgraphs with dynamic input sizes, so moving it would be needed for that anyway.
zhiics
approved these changes
Nov 7, 2020
Contributor
trevor-m
pushed a commit
to trevor-m/tvm
that referenced
this pull request
Dec 2, 2020
…pache#6872) * Allocate data buffers for gpu fix * Rename AllocateDeviceBuffer, update docstrings * Remove unneeded cast
trevor-m
pushed a commit
to trevor-m/tvm
that referenced
this pull request
Dec 4, 2020
…pache#6872) * Allocate data buffers for gpu fix * Rename AllocateDeviceBuffer, update docstrings * Remove unneeded cast
trevor-m
pushed a commit
to neo-ai/tvm
that referenced
this pull request
Dec 4, 2020
…pache#6872) * Allocate data buffers for gpu fix * Rename AllocateDeviceBuffer, update docstrings * Remove unneeded cast
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR enables the TRT BYOC integration to be used with target="llvm" (previously could only use "cuda").
If an input or output DLTensor is not located on the GPU, we will now allocate a GPU buffer to pass to TensorRT and transfer the data from the DLTensor accordingly. Since data_entry_ is needed during BuildEngine now, we had to move BuildEngine from JsonRuntime::Init to first run.
This is prerequisite to use TRT BYOC in combination with Relay VM which in general requires llvm target.
Thanks @ylc for original implementation: neo-ai#147