提交 2ec589a2 编写于 作者: D dzhwinter

float.h fixed

上级 7dceb8a0
......@@ -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)
......
......@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <limits>
#include <cfloat>
// 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<float>::max()
#endif // __FLT_MAX__
......@@ -19,23 +19,23 @@
#include <string>
#define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h
#include "glog/logging.h"
#if !defined(_WIN32)
#define UNUSED __attribute__((unused))
#include <dlfcn.h> // for dladdr
#include <execinfo.h> // for backtrace
#include <sys/stat.h>
#else
#include <io.h> // _popen, _pclose
#include <windows.h>
// 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
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册