Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
bd2fa736
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
bd2fa736
编写于
2月 19, 2019
作者:
T
Tao Luo
提交者:
GitHub
2月 19, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15794 from sneaxiy/fix-warnings
Fix compile warning
上级
e1c707fe
9b8e0e2f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
63 addition
and
9 deletion
+63
-9
paddle/fluid/platform/device_context.cc
paddle/fluid/platform/device_context.cc
+1
-1
paddle/fluid/platform/enforce.h
paddle/fluid/platform/enforce.h
+55
-7
paddle/fluid/platform/enforce_test.cc
paddle/fluid/platform/enforce_test.cc
+7
-1
未找到文件。
paddle/fluid/platform/device_context.cc
浏览文件 @
bd2fa736
...
...
@@ -291,7 +291,7 @@ CUDADeviceContext::CUDADeviceContext(CUDAPlace place)
if
(
dynload
::
HasCUDNN
())
{
auto
local_cudnn_version
=
cudnn_dso_ver
/
100
;
auto
compile_cudnn_version
=
CUDNN_VERSION
/
100
;
if
(
local_cudnn_version
<
compile_cudnn_version
)
{
if
(
local_cudnn_version
<
static_cast
<
size_t
>
(
compile_cudnn_version
)
)
{
LOG_FIRST_N
(
WARNING
,
1
)
<<
"WARNING: device: "
<<
place_
.
device
<<
". The installed Paddle is compiled with CUDNN "
...
...
paddle/fluid/platform/enforce.h
浏览文件 @
bd2fa736
...
...
@@ -31,6 +31,8 @@ limitations under the License. */
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>
#include "glog/logging.h"
#include "paddle/fluid/platform/macros.h"
...
...
@@ -280,16 +282,62 @@ inline void throw_on_error(ncclResult_t stat, const std::string& msg) {
} \
} while (0)
#define __PADDLE_BINARY_COMPARE(__VAL0, __VAL1, __CMP, __INV_CMP, ...) \
namespace
details
{
template
<
typename
T
>
inline
constexpr
bool
IsArithmetic
()
{
return
std
::
is_arithmetic
<
T
>::
value
;
}
template
<
typename
T1
,
typename
T2
,
bool
kIsArithmetic
/* = true */
>
struct
TypeConverterImpl
{
using
Type1
=
typename
std
::
common_type
<
T1
,
T2
>::
type
;
using
Type2
=
Type1
;
};
template
<
typename
T1
,
typename
T2
>
struct
TypeConverterImpl
<
T1
,
T2
,
false
>
{
using
Type1
=
T1
;
using
Type2
=
T2
;
};
template
<
typename
T1
,
typename
T2
>
struct
TypeConverter
{
private:
static
constexpr
bool
kIsArithmetic
=
IsArithmetic
<
T1
>
()
&&
IsArithmetic
<
T2
>
();
public:
using
Type1
=
typename
TypeConverterImpl
<
T1
,
T2
,
kIsArithmetic
>::
Type1
;
using
Type2
=
typename
TypeConverterImpl
<
T1
,
T2
,
kIsArithmetic
>::
Type2
;
};
template
<
typename
T1
,
typename
T2
>
using
CommonType1
=
typename
std
::
add_lvalue_reference
<
typename
std
::
add_const
<
typename
TypeConverter
<
T1
,
T2
>::
Type1
>::
type
>::
type
;
template
<
typename
T1
,
typename
T2
>
using
CommonType2
=
typename
std
::
add_lvalue_reference
<
typename
std
::
add_const
<
typename
TypeConverter
<
T1
,
T2
>::
Type2
>::
type
>::
type
;
}
// namespace details
#define __PADDLE_BINARY_COMPARE(__VAL1, __VAL2, __CMP, __INV_CMP, ...) \
do { \
auto __cond1__ = (__VAL0); \
auto __cond2__ = (__VAL1); \
if (UNLIKELY(!((__cond1__)__CMP(__cond2__)))) { \
auto __val1 = (__VAL1); \
auto __val2 = (__VAL2); \
using __TYPE1__ = decltype(__val1); \
using __TYPE2__ = decltype(__val2); \
using __COMMON_TYPE1__ = \
::paddle::platform::details::CommonType1<__TYPE1__, __TYPE2__>; \
using __COMMON_TYPE2__ = \
::paddle::platform::details::CommonType2<__TYPE1__, __TYPE2__>; \
bool __is_not_error = (static_cast<__COMMON_TYPE1__>(__val1))__CMP( \
static_cast<__COMMON_TYPE2__>(__val2)); \
if (UNLIKELY(!__is_not_error)) { \
PADDLE_THROW("Enforce failed. Expected %s " #__CMP \
" %s, but received %s:%s " #__INV_CMP " %s:%s.\n%s", \
#__VAL
0, #__VAL1, #__VAL0
, \
::paddle::string::to_string(__
cond1__), #__VAL1,
\
::paddle::string::to_string(__
cond2__),
\
#__VAL
1, #__VAL2, #__VAL1
, \
::paddle::string::to_string(__
val1), #__VAL2,
\
::paddle::string::to_string(__
val2),
\
::paddle::string::Sprintf(__VA_ARGS__)); \
} \
} while (0)
...
...
paddle/fluid/platform/enforce_test.cc
浏览文件 @
bd2fa736
...
...
@@ -234,7 +234,13 @@ TEST(ENFORCE_USER_DEFINED_CLASS, EQ) {
TEST
(
ENFORCE_USER_DEFINED_CLASS
,
NE
)
{
Dims
a
{{
1
,
2
,
3
,
4
}},
b
{{
5
,
6
,
7
,
8
}};
ASSERT_THROW
(
PADDLE_ENFORCE_EQ
(
a
,
b
),
paddle
::
platform
::
EnforceNotMet
);
bool
caught_exception
=
false
;
try
{
PADDLE_ENFORCE_EQ
(
a
,
b
);
}
catch
(
paddle
::
platform
::
EnforceNotMet
&
)
{
caught_exception
=
true
;
}
EXPECT_TRUE
(
caught_exception
);
}
TEST
(
EOF_EXCEPTION
,
THROW_EOF
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录