Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
93a2d9c5
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看板
未验证
提交
93a2d9c5
编写于
12月 18, 2017
作者:
Q
QI JUN
提交者:
GitHub
12月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add more place test and rename Cudnn to CUDNN (#6621)
* add more place_test and rename Cudnn to CUDNN * fix ci
上级
77cf7d4f
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
24 addition
and
18 deletion
+24
-18
paddle/operators/math/math_function.cu
paddle/operators/math/math_function.cu
+1
-1
paddle/platform/device_context.cc
paddle/platform/device_context.cc
+4
-4
paddle/platform/device_context.h
paddle/platform/device_context.h
+4
-4
paddle/platform/device_context_test.cc
paddle/platform/device_context_test.cc
+5
-5
paddle/platform/place.h
paddle/platform/place.h
+4
-4
paddle/platform/place_test.cc
paddle/platform/place_test.cc
+6
-0
未找到文件。
paddle/operators/math/math_function.cu
浏览文件 @
93a2d9c5
...
@@ -274,7 +274,7 @@ void set_constant_with_place<platform::GPUPlace>(
...
@@ -274,7 +274,7 @@ void set_constant_with_place<platform::GPUPlace>(
}
}
template
<
>
template
<
>
void
set_constant_with_place
<
platform
::
C
udnn
Place
>
(
void
set_constant_with_place
<
platform
::
C
UDNN
Place
>
(
const
platform
::
DeviceContext
&
context
,
framework
::
Tensor
*
tensor
,
const
platform
::
DeviceContext
&
context
,
framework
::
Tensor
*
tensor
,
float
value
)
{
float
value
)
{
set_constant_with_place
<
platform
::
GPUPlace
>
(
context
,
tensor
,
value
);
set_constant_with_place
<
platform
::
GPUPlace
>
(
context
,
tensor
,
value
);
...
...
paddle/platform/device_context.cc
浏览文件 @
93a2d9c5
...
@@ -125,21 +125,21 @@ cudnnHandle_t CUDADeviceContext::cudnn_handle() const { return cudnn_handle_; }
...
@@ -125,21 +125,21 @@ cudnnHandle_t CUDADeviceContext::cudnn_handle() const { return cudnn_handle_; }
cudaStream_t
CUDADeviceContext
::
stream
()
const
{
return
stream_
;
}
cudaStream_t
CUDADeviceContext
::
stream
()
const
{
return
stream_
;
}
C
udnnDeviceContext
::
CudnnDeviceContext
(
Cudnn
Place
place
)
C
UDNNDeviceContext
::
CUDNNDeviceContext
(
CUDNN
Place
place
)
:
CUDADeviceContext
(
place
),
place_
(
place
)
{
:
CUDADeviceContext
(
place
),
place_
(
place
)
{
PADDLE_ENFORCE
(
dynload
::
cudnnCreate
(
&
cudnn_handle_
));
PADDLE_ENFORCE
(
dynload
::
cudnnCreate
(
&
cudnn_handle_
));
PADDLE_ENFORCE
(
dynload
::
cudnnSetStream
(
cudnn_handle_
,
stream
()));
PADDLE_ENFORCE
(
dynload
::
cudnnSetStream
(
cudnn_handle_
,
stream
()));
}
}
C
udnnDeviceContext
::~
Cudnn
DeviceContext
()
{
C
UDNNDeviceContext
::~
CUDNN
DeviceContext
()
{
SetDeviceId
(
place_
.
device
);
SetDeviceId
(
place_
.
device
);
Wait
();
Wait
();
PADDLE_ENFORCE
(
dynload
::
cudnnDestroy
(
cudnn_handle_
));
PADDLE_ENFORCE
(
dynload
::
cudnnDestroy
(
cudnn_handle_
));
}
}
Place
C
udnnDeviceContext
::
GetPlace
()
const
{
return
Cudnn
Place
();
}
Place
C
UDNNDeviceContext
::
GetPlace
()
const
{
return
CUDNN
Place
();
}
cudnnHandle_t
C
udnn
DeviceContext
::
cudnn_handle
()
const
{
return
cudnn_handle_
;
}
cudnnHandle_t
C
UDNN
DeviceContext
::
cudnn_handle
()
const
{
return
cudnn_handle_
;
}
#endif
#endif
...
...
paddle/platform/device_context.h
浏览文件 @
93a2d9c5
...
@@ -86,10 +86,10 @@ class CUDADeviceContext : public DeviceContext {
...
@@ -86,10 +86,10 @@ class CUDADeviceContext : public DeviceContext {
cublasHandle_t
cublas_handle_
;
cublasHandle_t
cublas_handle_
;
};
};
class
C
udnn
DeviceContext
:
public
CUDADeviceContext
{
class
C
UDNN
DeviceContext
:
public
CUDADeviceContext
{
public:
public:
explicit
C
udnnDeviceContext
(
Cudnn
Place
place
);
explicit
C
UDNNDeviceContext
(
CUDNN
Place
place
);
virtual
~
C
udnn
DeviceContext
();
virtual
~
C
UDNN
DeviceContext
();
/*! \brief Return place in the device context. */
/*! \brief Return place in the device context. */
Place
GetPlace
()
const
final
;
Place
GetPlace
()
const
final
;
...
@@ -99,7 +99,7 @@ class CudnnDeviceContext : public CUDADeviceContext {
...
@@ -99,7 +99,7 @@ class CudnnDeviceContext : public CUDADeviceContext {
private:
private:
cudnnHandle_t
cudnn_handle_
;
cudnnHandle_t
cudnn_handle_
;
C
udnn
Place
place_
;
C
UDNN
Place
place_
;
};
};
#endif
#endif
...
...
paddle/platform/device_context_test.cc
浏览文件 @
93a2d9c5
...
@@ -47,14 +47,14 @@ TEST(Device, CUDADeviceContext) {
...
@@ -47,14 +47,14 @@ TEST(Device, CUDADeviceContext) {
}
}
}
}
TEST
(
Device
,
C
udnn
DeviceContext
)
{
TEST
(
Device
,
C
UDNN
DeviceContext
)
{
using
paddle
::
platform
::
C
udnn
DeviceContext
;
using
paddle
::
platform
::
C
UDNN
DeviceContext
;
using
paddle
::
platform
::
C
udnn
Place
;
using
paddle
::
platform
::
C
UDNN
Place
;
if
(
paddle
::
platform
::
dynload
::
HasCUDNN
())
{
if
(
paddle
::
platform
::
dynload
::
HasCUDNN
())
{
int
count
=
paddle
::
platform
::
GetCUDADeviceCount
();
int
count
=
paddle
::
platform
::
GetCUDADeviceCount
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
C
udnn
DeviceContext
*
device_context
=
C
UDNN
DeviceContext
*
device_context
=
new
C
udnnDeviceContext
(
Cudnn
Place
(
i
));
new
C
UDNNDeviceContext
(
CUDNN
Place
(
i
));
cudnnHandle_t
cudnn_handle
=
device_context
->
cudnn_handle
();
cudnnHandle_t
cudnn_handle
=
device_context
->
cudnn_handle
();
ASSERT_NE
(
nullptr
,
cudnn_handle
);
ASSERT_NE
(
nullptr
,
cudnn_handle
);
ASSERT_NE
(
nullptr
,
device_context
->
stream
());
ASSERT_NE
(
nullptr
,
device_context
->
stream
());
...
...
paddle/platform/place.h
浏览文件 @
93a2d9c5
...
@@ -51,9 +51,9 @@ struct GPUPlace {
...
@@ -51,9 +51,9 @@ struct GPUPlace {
int
device
;
int
device
;
};
};
struct
C
udnn
Place
:
public
GPUPlace
{
struct
C
UDNN
Place
:
public
GPUPlace
{
C
udnn
Place
()
:
GPUPlace
()
{}
C
UDNN
Place
()
:
GPUPlace
()
{}
explicit
C
udnn
Place
(
int
d
)
:
GPUPlace
(
d
)
{}
explicit
C
UDNN
Place
(
int
d
)
:
GPUPlace
(
d
)
{}
};
};
struct
IsGPUPlace
:
public
boost
::
static_visitor
<
bool
>
{
struct
IsGPUPlace
:
public
boost
::
static_visitor
<
bool
>
{
...
@@ -72,7 +72,7 @@ struct IsMKLDNNPlace : public boost::static_visitor<bool> {
...
@@ -72,7 +72,7 @@ struct IsMKLDNNPlace : public boost::static_visitor<bool> {
// should be less equal than 2^(NUM_PLACE_TYPE_LIMIT_IN_BIT)
// should be less equal than 2^(NUM_PLACE_TYPE_LIMIT_IN_BIT)
#define NUM_PLACE_TYPE_LIMIT_IN_BIT 4
#define NUM_PLACE_TYPE_LIMIT_IN_BIT 4
typedef
boost
::
variant
<
C
udnn
Place
,
GPUPlace
,
CPUPlace
,
MKLDNNPlace
>
Place
;
typedef
boost
::
variant
<
C
UDNN
Place
,
GPUPlace
,
CPUPlace
,
MKLDNNPlace
>
Place
;
// static check number of place types is less equal than
// static check number of place types is less equal than
// 2^(NUM_PLACE_TYPE_LIMIT_IN_BIT)
// 2^(NUM_PLACE_TYPE_LIMIT_IN_BIT)
...
...
paddle/platform/place_test.cc
浏览文件 @
93a2d9c5
...
@@ -5,16 +5,22 @@
...
@@ -5,16 +5,22 @@
TEST
(
Place
,
Equality
)
{
TEST
(
Place
,
Equality
)
{
paddle
::
platform
::
CPUPlace
cpu
;
paddle
::
platform
::
CPUPlace
cpu
;
paddle
::
platform
::
GPUPlace
g0
(
0
),
g1
(
1
),
gg0
(
0
);
paddle
::
platform
::
GPUPlace
g0
(
0
),
g1
(
1
),
gg0
(
0
);
paddle
::
platform
::
CUDNNPlace
d0
(
0
),
d1
(
1
),
dd0
(
0
);
EXPECT_EQ
(
cpu
,
cpu
);
EXPECT_EQ
(
cpu
,
cpu
);
EXPECT_EQ
(
g0
,
g0
);
EXPECT_EQ
(
g0
,
g0
);
EXPECT_EQ
(
g1
,
g1
);
EXPECT_EQ
(
g1
,
g1
);
EXPECT_EQ
(
g0
,
gg0
);
EXPECT_EQ
(
g0
,
gg0
);
EXPECT_EQ
(
d0
,
dd0
);
EXPECT_NE
(
g0
,
g1
);
EXPECT_NE
(
g0
,
g1
);
EXPECT_NE
(
d0
,
d1
);
EXPECT_TRUE
(
paddle
::
platform
::
places_are_same_class
(
g0
,
gg0
));
EXPECT_TRUE
(
paddle
::
platform
::
places_are_same_class
(
g0
,
gg0
));
EXPECT_FALSE
(
paddle
::
platform
::
places_are_same_class
(
g0
,
cpu
));
EXPECT_FALSE
(
paddle
::
platform
::
places_are_same_class
(
g0
,
cpu
));
EXPECT_TRUE
(
paddle
::
platform
::
is_gpu_place
(
d0
));
EXPECT_FALSE
(
paddle
::
platform
::
places_are_same_class
(
g0
,
d0
));
}
}
TEST
(
Place
,
Default
)
{
TEST
(
Place
,
Default
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录