From 1e01335e195d993f3c5c97bed3a15a6f9170acea Mon Sep 17 00:00:00 2001 From: Pei Yang Date: Tue, 11 Aug 2020 13:03:58 +0800 Subject: [PATCH] [cherry-pick]add macro check for using TRT api dynamicRangeIsSet() and hard_sigmoid (#26092) * add macro check for using TRT api dynamicRangeIsSet() (#25694) * adjust minimum trt version for hard_sigmoid converter to 5130. test=develop (#24746) --- paddle/fluid/inference/tensorrt/convert/hard_sigmoid_op.cc | 2 +- paddle/fluid/inference/tensorrt/engine.cc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/inference/tensorrt/convert/hard_sigmoid_op.cc b/paddle/fluid/inference/tensorrt/convert/hard_sigmoid_op.cc index 301b4140ac..7e94bd0c48 100644 --- a/paddle/fluid/inference/tensorrt/convert/hard_sigmoid_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/hard_sigmoid_op.cc @@ -25,7 +25,7 @@ class HardSigmoidOpConverter : public OpConverter { public: void operator()(const framework::proto::OpDesc& op, const framework::Scope& scope, bool test_mode) override { -#if IS_TRT_VERSION_GE(5000) +#if IS_TRT_VERSION_GE(5130) VLOG(3) << "convert a fluid HardSigmoid op to tensorrt IActivationLayer " "layer without bias"; framework::OpDesc op_desc(op, nullptr); diff --git a/paddle/fluid/inference/tensorrt/engine.cc b/paddle/fluid/inference/tensorrt/engine.cc index 4c0806ba30..9a72de15f3 100644 --- a/paddle/fluid/inference/tensorrt/engine.cc +++ b/paddle/fluid/inference/tensorrt/engine.cc @@ -124,6 +124,7 @@ void TensorRTEngine::FreezeNetwork() { << ", this might be ok when trt does not need this range"; } } +#if IS_TRT_VERSION_GE(5122) auto is_layer_int8 = [&](nvinfer1::ILayer *layer) -> bool { for (int j = 0; j < layer->getNbInputs(); j++) { auto *temp_in = layer->getInput(j); @@ -161,6 +162,11 @@ void TensorRTEngine::FreezeNetwork() { layer->setPrecision(nvinfer1::DataType::kFLOAT); } } +#else + LOG(WARNING) << "If your TensorRT version is lower than 5.1.2.2, you " + "must provide quantization scales for all tensors using " + "TRT to run."; +#endif #endif } } -- GitLab