From 2ec589a24e52466e11c1c12c24d612634f67fe82 Mon Sep 17 00:00:00 2001 From: dzhwinter Date: Sun, 26 Aug 2018 20:31:46 +0800 Subject: [PATCH] float.h fixed --- paddle/fluid/operators/math/CMakeLists.txt | 9 ++++++++- paddle/fluid/platform/macros.h | 4 +--- paddle/fluid/platform/port.h | 22 ++++++++++++++-------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/paddle/fluid/operators/math/CMakeLists.txt b/paddle/fluid/operators/math/CMakeLists.txt index 568f8f5c19..85256738c2 100644 --- a/paddle/fluid/operators/math/CMakeLists.txt +++ b/paddle/fluid/operators/math/CMakeLists.txt @@ -40,9 +40,16 @@ math_library(context_project DEPS im2col math_function) math_library(cross_entropy) math_library(cos_sim_functor) math_library(depthwise_conv) -math_library(gru_compute DEPS activation_functions math_function) math_library(im2col) +if (NOT WIN32) +math_library(gru_compute DEPS activation_functions math_function) math_library(lstm_compute DEPS activation_functions) +else() +# windows do not support avx functions yet. +math_library(gru_compute DEPS math_function) +math_library(lstm_compute DEPS math_function) +endif (NOT WIN32) + cc_library(blas SRCS blas.cc DEPS cblas framework_proto device_context) math_library(math_function DEPS blas) math_library(maxouting) diff --git a/paddle/fluid/platform/macros.h b/paddle/fluid/platform/macros.h index 5a6eaaa534..32b7efc04c 100644 --- a/paddle/fluid/platform/macros.h +++ b/paddle/fluid/platform/macros.h @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once -#include +#include // Disable the copy and assignment operator for a class. #ifndef DISABLE_COPY_AND_ASSIGN @@ -27,6 +27,4 @@ limitations under the License. */ #if defined(__FLT_MAX__) #define FLT_MAX __FLT_MAX__ -#else -#define FLT_MAX std::numeric_limits::max() #endif // __FLT_MAX__ diff --git a/paddle/fluid/platform/port.h b/paddle/fluid/platform/port.h index d36df26f09..2ceb2b0f5c 100644 --- a/paddle/fluid/platform/port.h +++ b/paddle/fluid/platform/port.h @@ -19,23 +19,23 @@ #include +#define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h +#include "glog/logging.h" + #if !defined(_WIN32) #define UNUSED __attribute__((unused)) - #include // for dladdr #include // for backtrace #include - #else #include // _popen, _pclose #include - // windows version of __attribute__((unused)) #define UNUSED __pragma(warning(suppress : 4100)) #ifndef S_ISDIR // windows port for sys/stat.h #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) -#endif +#endif // S_ISDIR static void *dlsym(void *handle, const char *symbol_name) { FARPROC found_symbol; @@ -49,8 +49,8 @@ static void *dlsym(void *handle, const char *symbol_name) { static void *dlopen(const char *filename, int flag) { std::string file_name(filename); - std::replace(file_name.begin(), file_name.end(), '/', '\\'); - HMODULE hModule = LoadLibrary(file_name); + file_name.replace(0, file_name.size() - 1, '/', '\\'); + HMODULE hModule = LoadLibrary(file_name.c_str()); if (!hModule) { throw std::runtime_error(file_name + " not found."); } @@ -123,14 +123,20 @@ static std::string DirName(const std::string &filepath) { } static void MkDir(const char *path) { + std::string path_error(path); + path_error += " mkdir failed!"; #if !defined(_WIN32) if (mkdir(path, 0755)) { - PADDLE_ENFORCE_EQ(errno, EEXIST, "%s mkdir failed!", path); + if (errno != EEXIST) { + throw std::runtime_error(path_error); + } } #else CreateDirectory(path, NULL); auto errorno = GetLastError(); - PADDLE_ENFORCE_EQ(errorno, ERROR_ALREADY_EXISTS, "%s mkdir failed!", path); + if (errorno != ERROR_ALREADY_EXISTS) { + throw std::runtime_error(path_error); + } #endif // !_WIN32 } -- GitLab