From f9e7cfb03ce7dce4721e16e0fad78bb2dd088247 Mon Sep 17 00:00:00 2001 From: wanghaoshuang Date: Tue, 23 Oct 2018 16:46:07 +0800 Subject: [PATCH] save binary file --- cmake/inference_lib.cmake | 15 +++++++++++---- paddle/fluid/operators/save_combine_op.cc | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index 514227a636a..3be45ea363b 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -51,11 +51,18 @@ function(copy TARGET) COMMAND ${CMAKE_COMMAND} -E copy "${src_file}" "${dst}" COMMENT "copying ${src_file} -> ${dst}") endforeach() - else() # not windows - add_custom_command(TARGET ${TARGET} PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory "${dst}" - COMMAND ${CMAKE_COMMAND} -E copy "${src_files}" "${dst}" + else(WIN32) # not windows + add_custom_command(TARGET ${TARGET} PRE_BUILD + COMMAND mkdir -p "${dst}" + COMMAND cp -r "${src}" "${dst}" COMMENT "copying ${src} -> ${dst}") + #add_custom_command(TARGET ${TARGET} PRE_BUILD + # COMMAND ${CMAKE_COMMAND} -E make_directory "${dst}") + #message("mkdir " ${TARGET}) + #add_custom_command(TARGET ${TARGET} PRE_BUILD + # COMMAND ${CMAKE_COMMAND} -E make_directory "${dst}" + # COMMAND ${CMAKE_COMMAND} -E copy_directory "${src_files}" "${dst}" + # COMMENT "copying ${src} -> ${dst}") endif(WIN32) endforeach() endfunction() diff --git a/paddle/fluid/operators/save_combine_op.cc b/paddle/fluid/operators/save_combine_op.cc index 5b05f757c03..6ab50964553 100644 --- a/paddle/fluid/operators/save_combine_op.cc +++ b/paddle/fluid/operators/save_combine_op.cc @@ -49,7 +49,7 @@ class SaveCombineOp : public framework::OperatorBase { } MkDirRecursively(DirName(filename).c_str()); - std::ofstream fout(filename); + std::ofstream fout(filename, std::ios_base::out | std::ios_base::binary); PADDLE_ENFORCE(static_cast(fout), "Cannot open %s to write", filename); -- GitLab