Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Batch Support for TRT #6955

Merged
merged 34 commits into from
Dec 1, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
GetBatchSizeFix
  • Loading branch information
Ubuntu committed Nov 24, 2020
commit 4d753223d23c44f0562874d0c6cc66b1353b5f9d
7 changes: 0 additions & 7 deletions src/runtime/contrib/tensorrt/tensorrt_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ class TensorRTRuntime : public JSONRuntimeBase {
void Run() override {
BuildEngine();
batch_size_ = data_entry_[input_var_eid_[0]]->shape[0];

// batch_size_ = GetBatchSize();
auto& engine_and_context = trt_engine_cache_.at(std::make_pair(symbol_name_, batch_size_));
auto engine = engine_and_context.engine;
auto context = engine_and_context.context;
Expand Down Expand Up @@ -178,7 +176,6 @@ class TensorRTRuntime : public JSONRuntimeBase {
* do nothing.
*/
void BuildEngine() {
// batch_size_ = GetBatchSize();
batch_size_ = data_entry_[input_var_eid_[0]]->shape[0];
if (trt_engine_cache_.count(std::make_pair(symbol_name_, batch_size_))) return;
LOG(INFO) << "Building new TensorRT engine for subgraph " << symbol_name_ << " with batch size "
Expand Down Expand Up @@ -262,8 +259,6 @@ class TensorRTRuntime : public JSONRuntimeBase {
* directory so it can be loaded later.
*/
void CacheEngineToDisk() {
// batch_size_ = GetBatchSize();

batch_size_ = data_entry_[input_var_eid_[0]]->shape[0];
std::string cache_dir = dmlc::GetEnv("TVM_TENSORRT_CACHE_DIR", std::string(""));
if (cache_dir.empty()) return;
Expand Down Expand Up @@ -303,8 +298,6 @@ class TensorRTRuntime : public JSONRuntimeBase {
auto nid = input_nodes_[i];
if (nodes_[nid].GetOpType() == "input") {
// Get batch size from first input.

LOG(INFO) << "Current Batch Size " << nodes_[nid].GetOpShape()[0][0];
return nodes_[nid].GetOpShape()[0][0];
}
}
Expand Down