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

fix(tensorrt): update tensorrt code of traffic_light_classifier #2325

Merged
merged 2 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
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
16 changes: 10 additions & 6 deletions perception/traffic_light_classifier/utils/trt_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@ void TrtCommon::setup()
}

context_ = UniquePtr<nvinfer1::IExecutionContext>(engine_->createExecutionContext());
input_dims_ = engine_->getBindingDimensions(getInputBindingIndex());
output_dims_ = engine_->getBindingDimensions(getOutputBindingIndex());

#if (NV_TENSORRT_MAJOR * 10000) + (NV_TENSORRT_MINOR * 100) + NV_TENSOR_PATCH >= 80500
input_dims_ = engine_->getTensorShape(input_name_.c_str());
output_dims_ = engine_->getTensorShape(output_name_.c_str());
#else
// Deprecated since 8.5
input_dims_ = engine_->getBindingDimensions(engine_->getBindingIndex(input_name_.c_str());
output_dims_ = engine_->getBindingDimensions(engine_->getBindingIndex(output_name_.c_str());
#endif

is_initialized_ = true;
}

Expand Down Expand Up @@ -155,8 +163,4 @@ int TrtCommon::getNumOutput()
output_dims_.d, output_dims_.d + output_dims_.nbDims, 1, std::multiplies<int>());
}

int TrtCommon::getInputBindingIndex() { return engine_->getBindingIndex(input_name_.c_str()); }

int TrtCommon::getOutputBindingIndex() { return engine_->getBindingIndex(output_name_.c_str()); }

} // namespace Tn
2 changes: 0 additions & 2 deletions perception/traffic_light_classifier/utils/trt_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ class TrtCommon
bool isInitialized();
int getNumInput();
int getNumOutput();
int getInputBindingIndex();
int getOutputBindingIndex();

UniquePtr<nvinfer1::IExecutionContext> context_;

Expand Down