fix trt serialization on windows (#31438)

fix_imperative_dygraph_error
Pei Yang 4 years ago committed by GitHub
parent 1321c47950
commit 30717a6cbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -244,7 +244,7 @@ static std::string GetTrtEngineSerializedData(
if (FileExists(trt_serialized_path)) { if (FileExists(trt_serialized_path)) {
VLOG(3) << "Trt serialized file: " << trt_serialized_path VLOG(3) << "Trt serialized file: " << trt_serialized_path
<< "is found here"; << "is found here";
std::ifstream infile(trt_serialized_path, std::ios::in); std::ifstream infile(trt_serialized_path, std::ios::binary);
std::stringstream buffer; std::stringstream buffer;
buffer << infile.rdbuf(); buffer << infile.rdbuf();
std::string trt_engine_serialized_data(buffer.str()); std::string trt_engine_serialized_data(buffer.str());
@ -256,7 +256,7 @@ static std::string GetTrtEngineSerializedData(
static void SaveTrtEngineSerializedDataToFile( static void SaveTrtEngineSerializedDataToFile(
const std::string &trt_serialized_path, const std::string &trt_serialized_path,
const std::string &engine_serialized_data) { 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 << engine_serialized_data;
outfile.close(); outfile.close();
} }

Loading…
Cancel
Save