Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
28172bbb
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
28172bbb
编写于
6月 30, 2018
作者:
Y
Yan Chunwei
提交者:
GitHub
6月 30, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add debug to replacing enforce with GLOG for debug (#11244)
上级
06da7402
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
41 addition
and
7 deletion
+41
-7
CMakeLists.txt
CMakeLists.txt
+5
-0
paddle/fluid/framework/tensor_impl.h
paddle/fluid/framework/tensor_impl.h
+6
-6
paddle/fluid/platform/enforce.h
paddle/fluid/platform/enforce.h
+29
-0
paddle/fluid/string/printf.h
paddle/fluid/string/printf.h
+1
-1
未找到文件。
CMakeLists.txt
浏览文件 @
28172bbb
...
...
@@ -61,6 +61,7 @@ option(EIGEN_USE_THREADS "Compile with multi-threaded Eigen" OFF)
option
(
WITH_ARM_FP16
"Use half precision support on armv8.2-a cpu"
OFF
)
option
(
WITH_FAST_BUNDLE_TEST
"Bundle tests that can be run in a single process together to reduce launch overhead"
OFF
)
option
(
WITH_CONTRIB
"Compile the third-party contributation"
OFF
)
option
(
REPLACE_ENFORCE_GLOG
"Replace PADDLE_ENFORCE with glog/CHECK for better debug."
OFF
)
option
(
WITH_ANAKIN
"Compile with Anakin library"
OFF
)
option
(
WITH_GRPC
"Use grpc as the default rpc framework"
${
WITH_DISTRIBUTE
}
)
...
...
@@ -131,6 +132,10 @@ if (NOT DEFINED WITH_MKLDNN)
set
(
WITH_MKLDNN OFF
)
endif
()
endif
()
if
(
REPLACE_ENFORCE_GLOG
)
add_definitions
(
"-DREPLACE_ENFORCE_GLOG"
)
endif
()
########################################################################################
include
(
external/mklml
)
# download mklml package
...
...
paddle/fluid/framework/tensor_impl.h
浏览文件 @
28172bbb
...
...
@@ -23,9 +23,9 @@ namespace framework {
template
<
typename
T
>
inline
const
T
*
Tensor
::
data
()
const
{
check_memory_size
();
PADDLE_ENFORCE
(
std
::
is_same
<
T
,
void
>::
value
||
holder_
->
type
()
==
std
::
type_index
(
typeid
(
T
)),
"Tensor holds the wrong type, it holds %s"
,
bool
valid
=
std
::
is_same
<
T
,
void
>::
value
||
holder_
->
type
()
==
std
::
type_index
(
typeid
(
T
));
PADDLE_ENFORCE
(
valid
,
"Tensor holds the wrong type, it holds %s"
,
this
->
holder_
->
type
().
name
());
return
reinterpret_cast
<
const
T
*>
(
...
...
@@ -37,9 +37,9 @@ inline bool Tensor::IsInitialized() const { return holder_ != nullptr; }
template
<
typename
T
>
inline
T
*
Tensor
::
data
()
{
check_memory_size
();
PADDLE_ENFORCE
(
std
::
is_same
<
T
,
void
>::
value
||
holder_
->
type
()
==
std
::
type_index
(
typeid
(
T
)),
"Tensor holds the wrong type, it holds %s"
,
bool
valid
=
std
::
is_same
<
T
,
void
>::
value
||
holder_
->
type
()
==
std
::
type_index
(
typeid
(
T
));
PADDLE_ENFORCE
(
valid
,
"Tensor holds the wrong type, it holds %s"
,
this
->
holder_
->
type
().
name
());
return
reinterpret_cast
<
T
*>
(
reinterpret_cast
<
uintptr_t
>
(
holder_
->
ptr
())
+
offset_
);
...
...
paddle/fluid/platform/enforce.h
浏览文件 @
28172bbb
...
...
@@ -113,7 +113,11 @@ template <typename... Args>
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
bool
stat
,
const
Args
&
...
args
)
{
if
(
UNLIKELY
(
!
(
stat
)))
{
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
string
::
Sprintf
(
args
...));
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...);
#endif
}
}
...
...
@@ -123,8 +127,12 @@ template <typename... Args>
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
cudaError_t
e
,
const
Args
&
...
args
)
{
if
(
UNLIKELY
(
e
))
{
#ifndef REPLACE_ENFORCE_GLOG
throw
thrust
::
system_error
(
e
,
thrust
::
cuda_category
(),
string
::
Sprintf
(
args
...));
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...);
#endif
}
}
...
...
@@ -132,8 +140,12 @@ template <typename... Args>
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
curandStatus_t
stat
,
const
Args
&
...
args
)
{
if
(
stat
!=
CURAND_STATUS_SUCCESS
)
{
#ifndef REPLACE_ENFORCE_GLOG
throw
thrust
::
system_error
(
cudaErrorLaunchFailure
,
thrust
::
cuda_category
(),
string
::
Sprintf
(
args
...));
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...);
#endif
}
}
...
...
@@ -143,8 +155,12 @@ inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
if
(
stat
==
CUDNN_STATUS_SUCCESS
)
{
return
;
}
else
{
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
platform
::
dynload
::
cudnnGetErrorString
(
stat
)
+
string
::
Sprintf
(
args
...));
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...);
#endif
}
}
...
...
@@ -173,7 +189,11 @@ inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
}
else
if
(
stat
==
CUBLAS_STATUS_LICENSE_ERROR
)
{
err
=
"CUBLAS: license error, "
;
}
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
err
+
string
::
Sprintf
(
args
...));
#else
LOG
(
FATAL
)
<<
err
<<
string
::
Sprintf
(
args
...);
#endif
}
#ifndef __APPLE__
...
...
@@ -183,8 +203,13 @@ inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
if
(
stat
==
ncclSuccess
)
{
return
;
}
else
{
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
platform
::
dynload
::
ncclGetErrorString
(
stat
)
+
string
::
Sprintf
(
args
...));
#else
LOG
(
FATAL
)
<<
platform
::
dynload
::
ncclGetErrorString
(
stat
)
<<
string
::
Sprintf
(
args
...);
#endif
}
}
#endif // __APPLE__
...
...
@@ -203,6 +228,7 @@ inline void throw_on_error(T e) {
__FILE__, __LINE__); \
} while (false)
#ifndef REPLACE_ENFORCE_GLOG
#define PADDLE_ENFORCE(...) \
do { \
try { \
...
...
@@ -212,6 +238,9 @@ inline void throw_on_error(T e) {
__FILE__, __LINE__); \
} \
} while (false)
#else
#define PADDLE_ENFORCE(...) ::paddle::platform::throw_on_error(__VA_ARGS__);
#endif
/*
* Some enforce helpers here, usage:
...
...
paddle/fluid/string/printf.h
浏览文件 @
28172bbb
...
...
@@ -84,7 +84,7 @@ void Fprintf(std::ostream& out, const char* fmt, const Args&... args) {
}
template
<
typename
...
Args
>
std
::
string
Sprintf
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
std
::
string
Sprintf
(
const
char
*
fmt
=
""
,
const
Args
&
...
args
)
{
std
::
ostringstream
oss
;
Fprintf
(
oss
,
fmt
,
args
...);
return
oss
.
str
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录