Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
64c6fb65
提交
64c6fb65
authored
4月 17, 2015
作者:
Caglar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added the new cpu assert opt.
上级
27060dbb
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
38 行增加
和
0 行删除
+38
-0
configdefaults.py
theano/configdefaults.py
+9
-0
opt.py
theano/sandbox/cuda/opt.py
+19
-0
test_opt.py
theano/sandbox/cuda/tests/test_opt.py
+10
-0
没有找到文件。
theano/configdefaults.py
浏览文件 @
64c6fb65
...
@@ -126,6 +126,15 @@ AddConfigVar(
...
@@ -126,6 +126,15 @@ AddConfigVar(
in_c_key
=
False
)
in_c_key
=
False
)
# This flag determines whether or not to raise error/warning message if there is a
# CPU in the computational graph.
AddConfigVar
(
'assert_no_cpu_op'
,
"Raise an error/warning if there is a CPU op in the computational graph."
,
EnumStr
(
'ignore'
,
'warn'
,
'raise'
,
'pdb'
,
allow_override
=
False
),
in_c_key
=
False
)
# Do not add FAST_RUN_NOGC to this list (nor any other ALL CAPS shortcut).
# Do not add FAST_RUN_NOGC to this list (nor any other ALL CAPS shortcut).
# The way to get FAST_RUN_NOGC is with the flag 'linker=c|py_nogc'.
# The way to get FAST_RUN_NOGC is with the flag 'linker=c|py_nogc'.
# The old all capital letter way of working is deprecated as it is not
# The old all capital letter way of working is deprecated as it is not
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
64c6fb65
...
@@ -446,6 +446,24 @@ def local_gpu_dot_to_dot22(node):
...
@@ -446,6 +446,24 @@ def local_gpu_dot_to_dot22(node):
return
False
return
False
@local_optimizer
([
gpu_from_host
,
host_from_gpu
])
def
local_assert_no_cpu_op
(
node
):
if
not
isinstance
(
node
.
op
,
GpuOp
)
and
all
([
var
.
owner
and
isinstance
(
var
.
owner
.
op
,
HostFromGpu
)
for
var
in
node
.
inputs
])
and
all
([
var
.
owner
and
isinstance
(
var
.
owner
.
op
,
GpuFromHost
)
for
var
in
node
.
outputs
]):
if
config
.
assert_no_cpu_op
==
"warn"
:
_logger
.
warning
((
"CPU op
%
s is detected in the computational"
" graph"
)
%
node
)
elif
config
.
assert_no_cpu_op
==
"raise"
:
raise
RuntimeError
(
"The op
%
s is on CPU."
%
node
)
elif
config
.
assert_no_cpu_op
==
"pdb"
:
import
ipdb
;
ipdb
.
set_trace
()
return
None
if
config
.
assert_no_cpu_op
!=
"ignore"
and
config
.
assert_no_cpu_op
:
register_opt
()(
local_assert_no_cpu_op
)
@register_opt
()
@register_opt
()
@local_optimizer
([
theano
.
ifelse
.
IfElse
,
gpu_from_host
])
@local_optimizer
([
theano
.
ifelse
.
IfElse
,
gpu_from_host
])
def
local_gpu_lazy_ifelse
(
node
):
def
local_gpu_lazy_ifelse
(
node
):
...
@@ -1911,6 +1929,7 @@ gpu_inplace_elemwise_optimizer = tensor.opt.inplace_elemwise_optimizer_op(
...
@@ -1911,6 +1929,7 @@ gpu_inplace_elemwise_optimizer = tensor.opt.inplace_elemwise_optimizer_op(
optdb
.
register
(
'gpu_inplace_elemwise_opt'
,
gpu_inplace_elemwise_optimizer
,
75
,
optdb
.
register
(
'gpu_inplace_elemwise_opt'
,
gpu_inplace_elemwise_optimizer
,
75
,
'fast_run'
,
'inplace'
,
'gpu_inplace'
)
'fast_run'
,
'inplace'
,
'gpu_inplace'
)
register_opt
()(
tensor
.
opt
.
local_remove_useless_assert
)
register_opt
()(
tensor
.
opt
.
local_remove_useless_assert
)
register_opt
()(
tensor
.
opt
.
local_shape_to_shape_i
)
register_opt
()(
tensor
.
opt
.
local_shape_to_shape_i
)
...
...
theano/sandbox/cuda/tests/test_opt.py
浏览文件 @
64c6fb65
...
@@ -91,6 +91,16 @@ def test_local_gpu_contiguous_gpu_contiguous():
...
@@ -91,6 +91,16 @@ def test_local_gpu_contiguous_gpu_contiguous():
if
isinstance
(
node
.
op
,
basic_ops
.
GpuContiguous
)])
if
isinstance
(
node
.
op
,
basic_ops
.
GpuContiguous
)])
def
test_local_assert_no_cpu_op
():
x
=
theano
.
tensor
.
fscalar
()
y
=
theano
.
tensor
.
fscalar
()
z
=
x
*
y
f
=
theano
.
function
([
x
,
y
],
z
,
mode
=
mode_with_gpu
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
a_op
=
[
n
for
n
in
topo
if
not
isinstance
(
n
.
op
,
cuda
.
GpuElemwise
)]
assert
len
(
a_op
)
==
3
def
test_int_pow
():
def
test_int_pow
():
a
=
CudaNdarrayType
([
False
])()
a
=
CudaNdarrayType
([
False
])()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论