diff --git a/paddle/fluid/inference/tensorrt/convert/cumsum_op.cc b/paddle/fluid/inference/tensorrt/convert/cumsum_op.cc index 3f5c186d1ab96aebd7e8d74e57e53e5c337f41a4..d8777d5edca4c2aca585ce529b0eac5b56e683c8 100644 --- a/paddle/fluid/inference/tensorrt/convert/cumsum_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/cumsum_op.cc @@ -51,7 +51,7 @@ class CumsumOpConverter : public OpConverter { return Add1DConstantLayer(d, "", scalar); } else { nvinfer1::ITensor* inpShape = Shape(inpTensor); - return GetEleTensorOfShape(inpShape, d, scalar); + return GetEleTensorOfShape(inpShape, axis, scalar); } }; diff --git a/paddle/fluid/inference/tensorrt/convert/op_converter.h b/paddle/fluid/inference/tensorrt/convert/op_converter.h index d61495bbb3fec2420cd7734f0a07781b3f2af45c..a7c569338b4d1b904ed9a35f53727266ffebe3a7 100644 --- a/paddle/fluid/inference/tensorrt/convert/op_converter.h +++ b/paddle/fluid/inference/tensorrt/convert/op_converter.h @@ -529,6 +529,12 @@ class OpConverter { nvinfer1::ITensor* GetEleTensorOfShape(nvinfer1::ITensor* shape_tensor, int index, bool is_scalar = false) { + PADDLE_ENFORCE_GE( + index, + 0, + platform::errors::PreconditionNotMet( + "The index should be greater or equal than 0, but got %d", index)); + auto* tensor = TRT_ENGINE_ADD_LAYER(engine_, Gather,