diff --git a/paddle/fluid/inference/analysis/helper.h b/paddle/fluid/inference/analysis/helper.h index 730fe35853a96a3427c26f1fa5662118a638f731..ab4949935140c682c7dee355a0e4ed9c2b3a1f5a 100644 --- a/paddle/fluid/inference/analysis/helper.h +++ b/paddle/fluid/inference/analysis/helper.h @@ -244,7 +244,7 @@ static std::string GetTrtEngineSerializedData( if (FileExists(trt_serialized_path)) { VLOG(3) << "Trt serialized file: " << trt_serialized_path << "is found here"; - std::ifstream infile(trt_serialized_path, std::ios::in); + std::ifstream infile(trt_serialized_path, std::ios::binary); std::stringstream buffer; buffer << infile.rdbuf(); std::string trt_engine_serialized_data(buffer.str()); @@ -256,7 +256,7 @@ static std::string GetTrtEngineSerializedData( static void SaveTrtEngineSerializedDataToFile( const std::string &trt_serialized_path, const std::string &engine_serialized_data) { - std::ofstream outfile(trt_serialized_path); + std::ofstream outfile(trt_serialized_path, std::ios::binary); outfile << engine_serialized_data; outfile.close(); }