You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by an...@apache.org on 2021/03/19 08:10:09 UTC

[tvm] branch main updated: Free TensorRT engine and context (#7702)

This is an automated email from the ASF dual-hosted git repository.

anijain2305 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 570767f  Free TensorRT engine and context (#7702)
570767f is described below

commit 570767f78851fbc0472c230adcb2c98e47bad0e8
Author: Trevor Morris <tr...@amazon.com>
AuthorDate: Fri Mar 19 01:09:45 2021 -0700

    Free TensorRT engine and context (#7702)
---
 src/runtime/contrib/tensorrt/tensorrt_runtime.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/runtime/contrib/tensorrt/tensorrt_runtime.cc b/src/runtime/contrib/tensorrt/tensorrt_runtime.cc
index 3f87f8d..e28c5a8 100644
--- a/src/runtime/contrib/tensorrt/tensorrt_runtime.cc
+++ b/src/runtime/contrib/tensorrt/tensorrt_runtime.cc
@@ -109,6 +109,14 @@ class TensorRTRuntime : public JSONRuntimeBase {
   }
 
 #ifdef TVM_GRAPH_RUNTIME_TENSORRT
+  /*! \brief Destroy engines and contexts. */
+  ~TensorRTRuntime() {
+    for (auto& it : trt_engine_cache_) {
+      it.second.context->destroy();
+      it.second.engine->destroy();
+    }
+  }
+
   /*! \brief Run inference using built engine. */
   void Run() override {
     BuildEngine();