Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
ba4f43fd
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ba4f43fd
编写于
1月 28, 2019
作者:
S
sneaxiy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compile error in distributed mode
test=develop
上级
5f89ce7f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
98 deletion
+45
-98
paddle/fluid/operators/distributed/proto_encoder_helper.h
paddle/fluid/operators/distributed/proto_encoder_helper.h
+1
-1
paddle/fluid/platform/enforce.h
paddle/fluid/platform/enforce.h
+41
-96
paddle/fluid/platform/nccl_helper.h
paddle/fluid/platform/nccl_helper.h
+1
-1
paddle/fluid/string/printf.h
paddle/fluid/string/printf.h
+2
-0
未找到文件。
paddle/fluid/operators/distributed/proto_encoder_helper.h
浏览文件 @
ba4f43fd
...
...
@@ -85,7 +85,7 @@ class ProtoEncodeHelper {
#define REPLACE_ENFORCE_GLOG 1
// Make sure callers didn't do operations that went over max_size promised
if
(
paddle
::
platform
::
is_error
(
p_
<=
limit_
))
{
paddle
::
platform
::
throw_on_error
(
p_
<=
limit_
);
paddle
::
platform
::
throw_on_error
(
p_
<=
limit_
,
""
);
}
#undef REPLACE_ENFORCE_GLOG
}
...
...
paddle/fluid/platform/enforce.h
浏览文件 @
ba4f43fd
...
...
@@ -71,9 +71,8 @@ struct EnforceNotMet : public std::exception {
}
}
template
<
typename
...
ARGS
>
EnforceNotMet
(
const
char
*
f
,
int
l
,
ARGS
...
args
)
{
Init
(
string
::
Sprintf
(
args
...),
f
,
l
);
EnforceNotMet
(
const
std
::
string
&
str
,
const
char
*
f
,
int
l
)
{
Init
(
str
,
f
,
l
);
}
const
char
*
what
()
const
noexcept
override
{
return
err_str_
.
c_str
();
}
...
...
@@ -142,28 +141,23 @@ struct EOFException : public std::exception {
inline
bool
is_error
(
bool
stat
)
{
return
!
stat
;
}
template
<
typename
...
Args
>
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
bool
stat
,
const
Args
&
...
args
)
{
inline
void
throw_on_error
(
bool
stat
,
const
std
::
string
&
msg
)
{
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
string
::
Sprintf
(
args
...)
);
throw
std
::
runtime_error
(
msg
);
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
msg
;
#endif
}
#ifdef PADDLE_WITH_CUDA
inline
bool
is_error
(
cudaError_t
e
)
{
return
UNLIKELY
(
e
)
;
}
inline
bool
is_error
(
cudaError_t
e
)
{
return
e
!=
cudaSuccess
;
}
template
<
typename
...
Args
>
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
cudaError_t
e
,
const
Args
&
...
args
)
{
inline
void
throw_on_error
(
cudaError_t
e
,
const
std
::
string
&
msg
)
{
#ifndef REPLACE_ENFORCE_GLOG
throw
thrust
::
system_error
(
e
,
thrust
::
cuda_category
(),
string
::
Sprintf
(
args
...));
throw
thrust
::
system_error
(
e
,
thrust
::
cuda_category
(),
msg
);
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
msg
;
#endif
}
...
...
@@ -171,14 +165,12 @@ inline bool is_error(curandStatus_t stat) {
return
stat
!=
CURAND_STATUS_SUCCESS
;
}
template
<
typename
...
Args
>
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
curandStatus_t
stat
,
const
Args
&
...
args
)
{
inline
void
throw_on_error
(
curandStatus_t
stat
,
const
std
::
string
&
msg
)
{
#ifndef REPLACE_ENFORCE_GLOG
throw
thrust
::
system_error
(
cudaErrorLaunchFailure
,
thrust
::
cuda_category
(),
string
::
Sprintf
(
args
...)
);
msg
);
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
msg
;
#endif
}
...
...
@@ -186,14 +178,11 @@ inline bool is_error(cudnnStatus_t stat) {
return
stat
!=
CUDNN_STATUS_SUCCESS
;
}
template
<
typename
...
Args
>
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
cudnnStatus_t
stat
,
const
Args
&
...
args
)
{
inline
void
throw_on_error
(
cudnnStatus_t
stat
,
const
std
::
string
&
msg
)
{
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
platform
::
dynload
::
cudnnGetErrorString
(
stat
)
+
string
::
Sprintf
(
args
...));
throw
std
::
runtime_error
(
platform
::
dynload
::
cudnnGetErrorString
(
stat
)
+
msg
);
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
platform
::
dynload
::
cudnnGetErrorString
(
stat
)
<<
msg
;
#endif
}
...
...
@@ -201,9 +190,7 @@ inline bool is_error(cublasStatus_t stat) {
return
stat
!=
CUBLAS_STATUS_SUCCESS
;
}
template
<
typename
...
Args
>
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
cublasStatus_t
stat
,
const
Args
&
...
args
)
{
inline
void
throw_on_error
(
cublasStatus_t
stat
,
const
std
::
string
&
msg
)
{
std
::
string
err
;
if
(
stat
==
CUBLAS_STATUS_NOT_INITIALIZED
)
{
err
=
"CUBLAS: not initialized, "
;
...
...
@@ -225,87 +212,45 @@ inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
err
=
"CUBLAS: license error, "
;
}
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
err
+
string
::
Sprintf
(
args
...)
);
throw
std
::
runtime_error
(
err
+
msg
);
#else
LOG
(
FATAL
)
<<
err
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
err
<<
msg
;
#endif
}
#if !defined(__APPLE__) && !defined(_WIN32)
template
<
typename
...
Args
>
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
ncclResult_t
stat
,
const
Args
&
...
args
)
{
if
(
stat
==
ncclSuccess
)
{
return
;
}
else
{
inline
bool
is_error
(
ncclResult_t
nccl_result
)
{
return
nccl_result
!=
ncclSuccess
;
}
inline
void
throw_on_error
(
ncclResult_t
stat
,
const
std
::
string
&
msg
)
{
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
platform
::
dynload
::
ncclGetErrorString
(
stat
)
+
string
::
Sprintf
(
args
...));
throw
std
::
runtime_error
(
platform
::
dynload
::
ncclGetErrorString
(
stat
)
+
msg
);
#else
LOG
(
FATAL
)
<<
platform
::
dynload
::
ncclGetErrorString
(
stat
)
<<
string
::
Sprintf
(
args
...);
LOG
(
FATAL
)
<<
platform
::
dynload
::
ncclGetErrorString
(
stat
)
<<
msg
;
#endif
}
}
#endif // __APPLE__ and windows
#endif // PADDLE_WITH_CUDA
template
<
typename
T
>
inline
void
throw_on_error
(
T
e
)
{
throw_on_error
(
e
,
""
);
}
#define PADDLE_THROW(...) \
throw ::paddle::platform::EnforceNotMet(__FILE__, __LINE__, __VA_ARGS__)
#define __PADDLE_THROW_ERROR_I(_, _9, _8, _7, _6, _5, _4, _3, _2, X_, ...) X_;
#define __THROW_ON_ERROR_ONE_ARG(COND, ARG) \
::paddle::platform::throw_on_error(COND, ::paddle::string::Sprintf(ARG));
#ifdef _WIN32
#define __PADDLE_THROW_ON_ERROR(COND, ...) \
__THROW_ON_ERROR_ONE_ARG(COND, __VA_ARGS__)
#else // _WIN32
#define __PADDLE_THROW_ON_ERROR(COND, ...) \
__PADDLE_THROW_ERROR_I( \
__VA_ARGS__, ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
__THROW_ON_ERROR_ONE_ARG(COND, __VA_ARGS__))
#endif // _WIN32
#define __PADDLE_UNARY_COMPARE(COND, ...) \
do { \
auto __cond = COND; \
if (UNLIKELY(::paddle::platform::is_error(__cond))) { \
__PADDLE_THROW_ON_ERROR(__cond, __VA_ARGS__); \
} \
#define PADDLE_THROW(...) \
throw ::paddle::platform::EnforceNotMet( \
::paddle::string::Sprintf(__VA_ARGS__), __FILE__, __LINE__)
#define PADDLE_ENFORCE(COND, ...) \
do { \
auto __cond__ = (COND); \
if (UNLIKELY(::paddle::platform::is_error(__cond__))) { \
try { \
::paddle::platform::throw_on_error( \
__cond__, ::paddle::string::Sprintf(__VA_ARGS__)); \
} catch (...) { \
throw ::paddle::platform::EnforceNotMet(std::current_exception(), \
__FILE__, __LINE__); \
} \
} \
} while (0)
#ifndef REPLACE_ENFORCE_GLOG
#define __PADDLE_ENFORCE_I(COND, ...) \
do { \
try { \
__PADDLE_UNARY_COMPARE(COND, __VA_ARGS__); \
} catch (...) { \
throw ::paddle::platform::EnforceNotMet(std::current_exception(), \
__FILE__, __LINE__); \
} \
} while (0)
#else
#define __PADDLE_ENFORCE_I(COND, ...) __PADDLE_UNARY_COMPARE(COND, __VA_ARGS__);
#endif // REPLACE_ENFORCE_GLOG
#define __PADDLE_ENFORCE(__args) __PADDLE_ENFORCE_I __args
#define PADDLE_ENFORCE(...) __PADDLE_ENFORCE((__VA_ARGS__))
#define PADDLE_THROW_EOF() \
do { \
throw ::paddle::platform::EOFException("There is no next data.", __FILE__, \
...
...
paddle/fluid/platform/nccl_helper.h
浏览文件 @
ba4f43fd
...
...
@@ -64,7 +64,7 @@ class NCCLGroupGuard {
}
inline
~
NCCLGroupGuard
()
{
CHECK_EQ
(
dynload
::
ncclGroupEnd
(),
ncclSuccess
);
PADDLE_ENFORCE
(
dynload
::
ncclGroupEnd
()
);
NCCLMutex
().
unlock
();
}
};
...
...
paddle/fluid/string/printf.h
浏览文件 @
ba4f43fd
...
...
@@ -84,6 +84,8 @@ void Fprintf(std::ostream& out, const char* fmt, const Args&... args) {
tinyformat
::
vformat
(
out
,
fmt
,
tinyformat
::
makeFormatList
(
args
...));
}
inline
std
::
string
Sprintf
()
{
return
""
;
}
template
<
typename
...
Args
>
std
::
string
Sprintf
(
const
Args
&
...
args
)
{
std
::
ostringstream
oss
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录