未验证 提交 1e8976e8 编写于 作者: Y Yuanle Liu 提交者: GitHub

fix trt engine memory sharing (#49584)

上级 0400eaed
...@@ -434,6 +434,7 @@ AnalysisConfig::AnalysisConfig(const AnalysisConfig &other) { ...@@ -434,6 +434,7 @@ AnalysisConfig::AnalysisConfig(const AnalysisConfig &other) {
CP_MEMBER(shape_range_info_path_); CP_MEMBER(shape_range_info_path_);
CP_MEMBER(trt_use_inspector_); CP_MEMBER(trt_use_inspector_);
CP_MEMBER(trt_engine_memory_sharing_); CP_MEMBER(trt_engine_memory_sharing_);
CP_MEMBER(trt_engine_memory_sharing_identifier_);
// Dlnne related // Dlnne related
CP_MEMBER(use_dlnne_); CP_MEMBER(use_dlnne_);
CP_MEMBER(dlnne_min_subgraph_size_); CP_MEMBER(dlnne_min_subgraph_size_);
......
...@@ -103,16 +103,17 @@ class AnalysisPredictor : public PaddlePredictor { ...@@ -103,16 +103,17 @@ class AnalysisPredictor : public PaddlePredictor {
if (config_.shape_range_info_collected()) { if (config_.shape_range_info_collected()) {
config_.SwitchIrOptim(false); config_.SwitchIrOptim(false);
} }
auto trt_identifier = config_.trt_engine_memory_sharing_identifier_; int trt_identifier = config_.trt_engine_memory_sharing_identifier_;
if (trt_identifier > 0) { if (trt_identifier > 0) {
// NOTE(liuyuanle): For convenience, we set the id of the predictor to // NOTE(liuyuanle): For convenience, we set the id of the predictor to
// negative sharing_identifier directly. In the future, this may affect // negative sharing_identifier directly. In the future, this may affect
// the meaning of negative predictor id. // the meaning of negative predictor id.
predictor_id_ = -trt_identifier; predictor_id_ = -trt_identifier;
LOG_FIRST_N(WARNING, 1) LOG(WARNING)
<< "Since the engine context memory of multiple predictors " << "Since the engine context memory of multiple predictors "
"is enabled in Paddle-TRT, we set the id of current predictor to " "is enabled in Paddle-TRT, we set the id of these predictors to "
"negative sharing_identifier you specified."; "negative sharing_identifier you specified : "
<< predictor_id_;
} else { } else {
predictor_id_ = inference::GetUniqueId(); predictor_id_ = inference::GetUniqueId();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册