Skip to content

Commit

Permalink
[cherry-pick]add macro check for using TRT api dynamicRangeIsSet() an…
Browse files Browse the repository at this point in the history
…d 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)
  • Loading branch information
cryoco authored Aug 11, 2020
1 parent acf95ba commit 1e01335
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion paddle/fluid/inference/tensorrt/convert/hard_sigmoid_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions paddle/fluid/inference/tensorrt/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit 1e01335

Please sign in to comment.