Skip to content

Commit

Permalink
fix ernie serialize problem
Browse files Browse the repository at this point in the history
  • Loading branch information
zlsh80826 committed Oct 26, 2021
1 parent 5119428 commit 5a2cae4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions paddle/fluid/inference/tensorrt/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ void TensorRTEngine::FreezeNetwork() {
*network(), *infer_builder_config_));
#else
infer_builder_config_->setFlag(nvinfer1::BuilderFlag::kSPARSE_WEIGHTS);
infer_ptr<nvinfer1::IHostMemory> plan(infer_builder_->buildSerializedNetwork(
ihost_memory_.reset(infer_builder_->buildSerializedNetwork(
*network(), *infer_builder_config_));
infer_ptr<nvinfer1::IRuntime> runtime(createInferRuntime(&logger_));
infer_engine_.reset(
runtime->deserializeCudaEngine(plan->data(), plan->size()));
infer_engine_.reset(runtime->deserializeCudaEngine(ihost_memory_->data(),
ihost_memory_->size()));
#endif

PADDLE_ENFORCE_NOT_NULL(
Expand Down
7 changes: 7 additions & 0 deletions paddle/fluid/inference/tensorrt/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,14 @@ class TensorRTEngine {
infer_engine_,
platform::errors::InvalidArgument(
"The TensorRT engine must be built first before serialization"));
#if IS_TRT_VERSION_LT(8000)
ihost_memory_.reset(infer_engine_->serialize());
#else
PADDLE_ENFORCE_NOT_NULL(
ihost_memory_,
platform::errors::InvalidArgument(
"TensorRT >= 8.0 requires that buildSerializedNetwork is called"));
#endif
return ihost_memory_.get();
}

Expand Down

1 comment on commit 5a2cae4

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.