From 30717a6cbcfb0d0b104eace9115e59cbe715010b Mon Sep 17 00:00:00 2001 From: Pei Yang Date: Fri, 5 Mar 2021 13:32:16 +0800 Subject: [PATCH] fix trt serialization on windows (#31438) --- paddle/fluid/inference/analysis/helper.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/inference/analysis/helper.h b/paddle/fluid/inference/analysis/helper.h index 730fe35853a..ab494993514 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(); } -- GitLab