Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
604d4d2b
提交
604d4d2b
authored
11月 28, 2014
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2307 from nouiz/dnn_pool
CRASH/OPT fix (quick to review)
上级
f5d4ed30
1dce9aeb
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
42 行增加
和
11 行删除
+42
-11
cc.py
theano/gof/cc.py
+18
-7
dnn.py
theano/sandbox/cuda/dnn.py
+5
-3
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+1
-1
type.py
theano/sandbox/cuda/type.py
+18
-0
没有找到文件。
theano/gof/cc.py
浏览文件 @
604d4d2b
...
@@ -343,17 +343,18 @@ def get_c_extract(r, name, sub):
...
@@ -343,17 +343,18 @@ def get_c_extract(r, name, sub):
if
any
([
getattr
(
c
.
op
,
'check_input'
,
config
.
check_input
)
for
(
c
,
_
)
in
if
any
([
getattr
(
c
.
op
,
'check_input'
,
config
.
check_input
)
for
(
c
,
_
)
in
r
.
clients
]):
r
.
clients
]):
# check_broadcast is just an hack to easily remove just the
# check_broadcast is just an hack to easily remove just the
# broadcast check on the old GPU back-end. T
H
is check isn't
# broadcast check on the old GPU back-end. T
h
is check isn't
# done in the new GPU back-end or on the CPU.
# done in the new GPU back-end or on the CPU.
if
hasattr
(
c
.
op
,
'check_broadcast'
):
if
any
([
getattr
(
c
.
op
,
'check_broadcast'
,
True
)
for
(
c
,
_
)
in
r
.
clients
]):
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
True
)
else
:
try
:
try
:
c_extract
=
r
.
type
.
c_extract
(
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
True
,
name
,
sub
,
True
,
check_broadcast
=
c
.
op
.
check_broadcast
)
check_broadcast
=
False
)
except
TypeError
,
e
:
except
TypeError
,
e
:
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
True
)
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
True
)
else
:
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
True
)
else
:
else
:
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
False
)
c_extract
=
r
.
type
.
c_extract
(
name
,
sub
,
False
)
...
@@ -366,8 +367,18 @@ def get_c_extract(r, name, sub):
...
@@ -366,8 +367,18 @@ def get_c_extract(r, name, sub):
def
get_c_extract_out
(
r
,
name
,
sub
):
def
get_c_extract_out
(
r
,
name
,
sub
):
"""Wrapper around c_extract_out that initializes py_name from storage."""
"""Wrapper around c_extract_out that initializes py_name from storage."""
c_extract
=
r
.
type
.
c_extract_out
(
name
,
sub
,
# check_broadcast is just an hack to easily remove just the
getattr
(
r
.
owner
.
op
,
'check_input'
,
config
.
check_input
))
# broadcast check on the old GPU back-end. This check isn't
# done in the new GPU back-end or on the CPU.
check_input
=
getattr
(
r
.
owner
.
op
,
'check_input'
,
config
.
check_input
)
if
getattr
(
r
.
owner
.
op
,
'check_broadcast'
,
True
):
c_extract
=
r
.
type
.
c_extract_out
(
name
,
sub
,
check_input
)
else
:
try
:
c_extract
=
r
.
type
.
c_extract_out
(
name
,
sub
,
check_input
,
check_broadcast
=
False
)
except
TypeError
,
e
:
c_extract
=
r
.
type
.
c_extract_out
(
name
,
sub
,
check_input
)
pre
=
"""
pre
=
"""
py_
%(name)
s = PyList_GET_ITEM(storage_
%(name)
s, 0);
py_
%(name)
s = PyList_GET_ITEM(storage_
%(name)
s, 0);
...
...
theano/sandbox/cuda/dnn.py
浏览文件 @
604d4d2b
...
@@ -88,6 +88,10 @@ class DnnBase(GpuOp):
...
@@ -88,6 +88,10 @@ class DnnBase(GpuOp):
"""
"""
Creates a handle for cudnn and pulls in the cudnn libraries and headers.
Creates a handle for cudnn and pulls in the cudnn libraries and headers.
"""
"""
# dnn does not know about broadcasting, so we do not need to assert
# the input broadcasting pattern.
check_broadcast
=
False
def
c_headers
(
self
):
def
c_headers
(
self
):
return
[
'cudnn.h'
,
'cudnn_helper.h'
]
return
[
'cudnn.h'
,
'cudnn_helper.h'
]
...
@@ -244,7 +248,6 @@ class GpuDnnConvDesc(GpuOp):
...
@@ -244,7 +248,6 @@ class GpuDnnConvDesc(GpuOp):
class
GpuDnnConvBase
(
DnnBase
):
class
GpuDnnConvBase
(
DnnBase
):
__props__
=
()
__props__
=
()
check_broadcast
=
False
def
c_support_code_struct
(
self
,
node
,
struct_id
):
def
c_support_code_struct
(
self
,
node
,
struct_id
):
return
"""
return
"""
...
@@ -1274,8 +1277,7 @@ if True:
...
@@ -1274,8 +1277,7 @@ if True:
border_mode
=
border_mode
,
subsample
=
subsample
,
border_mode
=
border_mode
,
subsample
=
subsample
,
direction_hint
=
direction_hint
)]
direction_hint
=
direction_hint
)]
# DISABLED as there is problems in the handling of borders
@register_opt
(
'cudnn'
)
# @register_opt('cudnn')
@local_optimizer
([
GpuDownsampleFactorMax
])
@local_optimizer
([
GpuDownsampleFactorMax
])
def
local_pool_dnn
(
node
):
def
local_pool_dnn
(
node
):
if
not
dnn_available
():
if
not
dnn_available
():
...
...
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
604d4d2b
...
@@ -178,7 +178,7 @@ def test_dnn_tag():
...
@@ -178,7 +178,7 @@ def test_dnn_tag():
try
:
try
:
f
=
theano
.
function
(
f
=
theano
.
function
(
[
x
],
[
x
],
max_pool_2d
(
x
,
ds
=
(
2
,
2
)),
max_pool_2d
(
x
,
ds
=
(
2
,
2
)
,
ignore_border
=
True
),
mode
=
mode_with_gpu
.
including
(
"cudnn"
))
mode
=
mode_with_gpu
.
including
(
"cudnn"
))
except
(
AssertionError
,
RuntimeError
),
e
:
except
(
AssertionError
,
RuntimeError
),
e
:
assert
not
cuda
.
dnn
.
dnn_available
()
assert
not
cuda
.
dnn
.
dnn_available
()
...
...
theano/sandbox/cuda/type.py
浏览文件 @
604d4d2b
...
@@ -360,6 +360,24 @@ class CudaNdarrayType(Type):
...
@@ -360,6 +360,24 @@ class CudaNdarrayType(Type):
#print sio.getvalue()
#print sio.getvalue()
return
sio
.
getvalue
()
return
sio
.
getvalue
()
def
c_extract_out
(
self
,
name
,
sub
,
check_input
=
True
,
check_broadcast
=
True
):
""" To allow the hack to skip check_broadcast.
"""
return
"""
if (py_
%(name)
s == Py_None)
{
%(c_init_code)
s
}
else
{
%(c_extract_code)
s
}
"""
%
dict
(
name
=
name
,
c_init_code
=
self
.
c_init
(
name
,
sub
),
c_extract_code
=
self
.
c_extract
(
name
,
sub
,
check_input
,
check_broadcast
))
def
c_cleanup
(
self
,
name
,
sub
):
def
c_cleanup
(
self
,
name
,
sub
):
return
"""
return
"""
//std::cerr << "cleanup " << py_
%(name)
s << " " <<
%(name)
s << "
\\
n";
//std::cerr << "cleanup " << py_
%(name)
s << " " <<
%(name)
s << "
\\
n";
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论