From 75a2f9d54ffd7e7a4cacaf16b3e1088b63882ebf Mon Sep 17 00:00:00 2001 From: wenbin Date: Tue, 28 Feb 2023 10:55:15 +0800 Subject: [PATCH] fix concat axis bug (#50951) * fix concat bug * recommit for ci --- paddle/fluid/inference/tensorrt/convert/concat_op.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/inference/tensorrt/convert/concat_op.cc b/paddle/fluid/inference/tensorrt/convert/concat_op.cc index a248178338c..9cf40b92940 100644 --- a/paddle/fluid/inference/tensorrt/convert/concat_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/concat_op.cc @@ -45,10 +45,11 @@ class ConcatOpConverter : public OpConverter { itensors.push_back(engine_->GetITensor(input_name)); } int axis = PADDLE_GET_CONST(int, op_desc.GetAttr("axis")); - if (axis == -1) { - axis = (engine_->GetITensor(op_desc.Input("X").front())->getDimensions()) - .nbDims - - 1; + if (axis < 0) { + axis = engine_->GetITensor(op_desc.Input("X").front()) + ->getDimensions() + .nbDims + + axis; } else { if (!engine_->with_dynamic_shape()) { axis = axis - 1; // Remove batch dim -- GitLab