Skip to content

Commit 1e01335

Browse files
author
Pei Yang
authored
[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)
1 parent acf95ba commit 1e01335

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

paddle/fluid/inference/tensorrt/convert/hard_sigmoid_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class HardSigmoidOpConverter : public OpConverter {
2525
public:
2626
void operator()(const framework::proto::OpDesc& op,
2727
const framework::Scope& scope, bool test_mode) override {
28-
#if IS_TRT_VERSION_GE(5000)
28+
#if IS_TRT_VERSION_GE(5130)
2929
VLOG(3) << "convert a fluid HardSigmoid op to tensorrt IActivationLayer "
3030
"layer without bias";
3131
framework::OpDesc op_desc(op, nullptr);

paddle/fluid/inference/tensorrt/engine.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ void TensorRTEngine::FreezeNetwork() {
124124
<< ", this might be ok when trt does not need this range";
125125
}
126126
}
127+
#if IS_TRT_VERSION_GE(5122)
127128
auto is_layer_int8 = [&](nvinfer1::ILayer *layer) -> bool {
128129
for (int j = 0; j < layer->getNbInputs(); j++) {
129130
auto *temp_in = layer->getInput(j);
@@ -161,6 +162,11 @@ void TensorRTEngine::FreezeNetwork() {
161162
layer->setPrecision(nvinfer1::DataType::kFLOAT);
162163
}
163164
}
165+
#else
166+
LOG(WARNING) << "If your TensorRT version is lower than 5.1.2.2, you "
167+
"must provide quantization scales for all tensors using "
168+
"TRT to run.";
169+
#endif
164170
#endif
165171
}
166172
}

0 commit comments

Comments
 (0)