From e123b98e7b2fd65796052a26c08b62bde1d6e23e Mon Sep 17 00:00:00 2001 From: Wilber Date: Sun, 23 Apr 2023 11:06:25 +0800 Subject: [PATCH] fix paddle-trt bug when encounter inplace var + weight share condition. (#53184) --- .../analysis/ir_passes/tensorrt_subgraph_pass.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/paddle/fluid/inference/analysis/ir_passes/tensorrt_subgraph_pass.cc b/paddle/fluid/inference/analysis/ir_passes/tensorrt_subgraph_pass.cc index 1ae64983e0c..b64d2bd16ce 100644 --- a/paddle/fluid/inference/analysis/ir_passes/tensorrt_subgraph_pass.cc +++ b/paddle/fluid/inference/analysis/ir_passes/tensorrt_subgraph_pass.cc @@ -297,6 +297,16 @@ void TensorRtSubgraphPass::CreateTensorRTOp( } } + // var may have the same name but not have the same id. + // e.g., var(batch_norm2d_0.w_1) may have id: 10, 13, 25.... in a graph. + // so we must find all the var_name+id. + // https://github.com/PaddlePaddle/Paddle/pull/53184 + for (auto *n : graph->Nodes()) { + if (n->IsVar() && input_names.count(n->Name())) { + input_names_with_id.insert(n->Name() + std::to_string(n->id())); + } + } + auto model_precision = static_cast(Get("model_precision")); auto mixed_black_list = -- GitLab