From eef98b7f8602b5bd740ceab5f74b19bea66ed853 Mon Sep 17 00:00:00 2001 From: Pei Yang Date: Tue, 28 Jul 2020 16:58:18 +0800 Subject: [PATCH] add macro check for using TRT api dynamicRangeIsSet() (#25694) --- paddle/fluid/inference/tensorrt/engine.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/paddle/fluid/inference/tensorrt/engine.cc b/paddle/fluid/inference/tensorrt/engine.cc index e1e1be6831..03f5a75151 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