Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
c4203751
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c4203751
编写于
2月 21, 2019
作者:
Z
Zeng Jinle
提交者:
GitHub
2月 21, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15806 from sneaxiy/fix-compiler
Fix compiler.py place compare bug
上级
971f3bc9
d331e97a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
2 deletion
+29
-2
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+28
-1
python/paddle/fluid/compiler.py
python/paddle/fluid/compiler.py
+1
-1
未找到文件。
paddle/fluid/pybind/pybind.cc
浏览文件 @
c4203751
...
@@ -106,6 +106,11 @@ bool IsCompiledWithDIST() {
...
@@ -106,6 +106,11 @@ bool IsCompiledWithDIST() {
#endif
#endif
}
}
template
<
typename
PlaceType1
,
typename
PlaceType2
>
static
inline
bool
IsSamePlace
(
const
PlaceType1
&
p1
,
const
PlaceType2
&
p2
)
{
return
paddle
::
platform
::
Place
(
p1
)
==
paddle
::
platform
::
Place
(
p2
);
}
PYBIND11_MODULE
(
core
,
m
)
{
PYBIND11_MODULE
(
core
,
m
)
{
// Not used, just make sure cpu_info.cc is linked.
// Not used, just make sure cpu_info.cc is linked.
paddle
::
platform
::
CpuTotalPhysicalMemory
();
paddle
::
platform
::
CpuTotalPhysicalMemory
();
...
@@ -732,23 +737,45 @@ All parameter, weight, gradient are variables in Paddle.
...
@@ -732,23 +737,45 @@ All parameter, weight, gradient are variables in Paddle.
PADDLE_THROW
(
"Cannot use CUDAPlace in CPU only version"
);
PADDLE_THROW
(
"Cannot use CUDAPlace in CPU only version"
);
#endif
#endif
})
})
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CUDAPlace
,
platform
::
Place
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CUDAPlace
,
platform
::
CUDAPlace
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CUDAPlace
,
platform
::
CPUPlace
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CUDAPlace
,
platform
::
CUDAPinnedPlace
>
)
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CUDAPlace
&>
);
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CUDAPlace
&>
);
py
::
class_
<
paddle
::
platform
::
CPUPlace
>
(
m
,
"CPUPlace"
)
py
::
class_
<
paddle
::
platform
::
CPUPlace
>
(
m
,
"CPUPlace"
)
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<>
())
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CPUPlace
,
platform
::
Place
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CPUPlace
,
platform
::
CUDAPlace
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CPUPlace
,
platform
::
CPUPlace
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CPUPlace
,
platform
::
CUDAPinnedPlace
>
)
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CPUPlace
&>
);
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CPUPlace
&>
);
py
::
class_
<
paddle
::
platform
::
CUDAPinnedPlace
>
(
m
,
"CUDAPinnedPlace"
)
py
::
class_
<
paddle
::
platform
::
CUDAPinnedPlace
>
(
m
,
"CUDAPinnedPlace"
)
.
def
(
"__init__"
,
.
def
(
"__init__"
,
[](
platform
::
CUDAPinnedPlace
&
)
{
[](
platform
::
CUDAPinnedPlace
&
self
)
{
#ifndef PADDLE_WITH_CUDA
#ifndef PADDLE_WITH_CUDA
PADDLE_THROW
(
"Cannot use CUDAPinnedPlace in CPU only version"
);
PADDLE_THROW
(
"Cannot use CUDAPinnedPlace in CPU only version"
);
#endif
#endif
new
(
&
self
)
platform
::
CUDAPinnedPlace
();
})
})
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CUDAPinnedPlace
,
platform
::
Place
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CUDAPinnedPlace
,
platform
::
CUDAPlace
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CUDAPinnedPlace
,
platform
::
CPUPlace
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
CUDAPinnedPlace
,
platform
::
CUDAPinnedPlace
>
)
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CUDAPinnedPlace
&>
);
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CUDAPinnedPlace
&>
);
py
::
class_
<
platform
::
Place
>
(
m
,
"Place"
)
py
::
class_
<
platform
::
Place
>
(
m
,
"Place"
)
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<>
())
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
Place
,
platform
::
Place
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
Place
,
platform
::
CUDAPlace
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
Place
,
platform
::
CPUPlace
>
)
.
def
(
"_equals"
,
&
IsSamePlace
<
platform
::
Place
,
platform
::
CUDAPinnedPlace
>
)
.
def
(
"is_gpu_place"
,
.
def
(
"is_gpu_place"
,
[](
platform
::
Place
&
self
)
{
return
platform
::
is_gpu_place
(
self
);
})
[](
platform
::
Place
&
self
)
{
return
platform
::
is_gpu_place
(
self
);
})
.
def
(
"gpu_device_id"
,
.
def
(
"gpu_device_id"
,
...
...
python/paddle/fluid/compiler.py
浏览文件 @
c4203751
...
@@ -220,7 +220,7 @@ class CompiledProgram(object):
...
@@ -220,7 +220,7 @@ class CompiledProgram(object):
if
self
.
_compiled
:
if
self
.
_compiled
:
if
scope
and
self
.
_scope
!=
scope
:
if
scope
and
self
.
_scope
!=
scope
:
raise
ValueError
(
"Cannot compile with different scope"
)
raise
ValueError
(
"Cannot compile with different scope"
)
if
place
and
self
.
_place
!=
place
:
if
place
and
not
self
.
_place
.
_equals
(
place
)
:
raise
ValueError
(
"Cannot compile with different place"
)
raise
ValueError
(
"Cannot compile with different place"
)
return
self
return
self
self
.
_compiled
=
True
self
.
_compiled
=
True
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录