Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b7f0c300
提交
b7f0c300
authored
2月 10, 2016
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Only raise error if convolution or pooling are used in the new back-end.
上级
733adf01
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
9 行删除
+15
-9
__init__.py
theano/sandbox/gpuarray/__init__.py
+1
-1
dnn.py
theano/sandbox/gpuarray/dnn.py
+14
-8
没有找到文件。
theano/sandbox/gpuarray/__init__.py
浏览文件 @
b7f0c300
...
@@ -77,7 +77,7 @@ def init_dev(dev, name=None):
...
@@ -77,7 +77,7 @@ def init_dev(dev, name=None):
" downgrading CuDNN to version 4."
)
" downgrading CuDNN to version 4."
)
cudnn_version
=
" (CuDNN version
%
s)"
%
cudnn_version
cudnn_version
=
" (CuDNN version
%
s)"
%
cudnn_version
except
Exception
:
except
Exception
:
raise
RuntimeError
(
"CuDNN is mandatory with the GpuArray back-end."
)
pass
print
(
"Mapped name
%
s to device
%
s:
%
s
%
s"
%
(
print
(
"Mapped name
%
s to device
%
s:
%
s
%
s"
%
(
name
,
dev
,
context
.
devname
,
cudnn_version
),
name
,
dev
,
context
.
devname
,
cudnn_version
),
file
=
sys
.
stderr
)
file
=
sys
.
stderr
)
...
...
theano/sandbox/gpuarray/dnn.py
浏览文件 @
b7f0c300
...
@@ -32,6 +32,10 @@ from .opt import gpu_seqopt, register_opt, conv_groupopt, op_lifter
...
@@ -32,6 +32,10 @@ from .opt import gpu_seqopt, register_opt, conv_groupopt, op_lifter
from
.opt_util
import
alpha_merge
,
output_merge
,
inplace_allocempty
from
.opt_util
import
alpha_merge
,
output_merge
,
inplace_allocempty
def
raise_no_cudnn
(
msg
=
"CuDNN is required for convolution and pooling"
):
raise
RuntimeError
(
msg
)
def
_dnn_check_compile
():
def
_dnn_check_compile
():
preambule
=
"""
preambule
=
"""
#include <stdio.h>
#include <stdio.h>
...
@@ -1302,10 +1306,12 @@ def local_abstractconv_cudnn(node):
...
@@ -1302,10 +1306,12 @@ def local_abstractconv_cudnn(node):
inp1
=
node
.
inputs
[
0
]
inp1
=
node
.
inputs
[
0
]
inp2
=
node
.
inputs
[
1
]
inp2
=
node
.
inputs
[
1
]
if
(
not
isinstance
(
inp1
.
type
,
GpuArrayType
)
or
if
not
isinstance
(
inp1
.
type
,
GpuArrayType
):
not
dnn_available
(
inp1
.
type
.
context_name
)):
return
None
return
None
if
not
dnn_available
(
inp1
.
type
.
context_name
):
raise_no_cudnn
()
if
node
.
op
.
filter_flip
:
if
node
.
op
.
filter_flip
:
conv_mode
=
'conv'
conv_mode
=
'conv'
else
:
else
:
...
@@ -1404,7 +1410,7 @@ def local_dnn_convi_output_merge(node, *inputs):
...
@@ -1404,7 +1410,7 @@ def local_dnn_convi_output_merge(node, *inputs):
@op_lifter
([
Pool
])
@op_lifter
([
Pool
])
def
local_pool_dnn_alternative
(
node
,
ctx_name
):
def
local_pool_dnn_alternative
(
node
,
ctx_name
):
if
not
dnn_available
(
ctx_name
):
if
not
dnn_available
(
ctx_name
):
r
eturn
r
aise_no_cudnn
()
if
not
node
.
op
.
ignore_border
:
if
not
node
.
op
.
ignore_border
:
return
return
img
,
=
node
.
inputs
img
,
=
node
.
inputs
...
@@ -1420,7 +1426,7 @@ def local_pool_dnn_alternative(node, ctx_name):
...
@@ -1420,7 +1426,7 @@ def local_pool_dnn_alternative(node, ctx_name):
@op_lifter
([
MaxPoolGrad
])
@op_lifter
([
MaxPoolGrad
])
def
local_pool_dnn_grad_stride
(
node
,
ctx_name
):
def
local_pool_dnn_grad_stride
(
node
,
ctx_name
):
if
not
dnn_available
(
ctx_name
):
if
not
dnn_available
(
ctx_name
):
r
eturn
r
aise_no_cudnn
()
if
not
node
.
op
.
ignore_border
:
if
not
node
.
op
.
ignore_border
:
return
return
inp
,
out
,
out_grad
=
node
.
inputs
inp
,
out
,
out_grad
=
node
.
inputs
...
@@ -1443,7 +1449,7 @@ def local_pool_dnn_grad_stride(node, ctx_name):
...
@@ -1443,7 +1449,7 @@ def local_pool_dnn_grad_stride(node, ctx_name):
@op_lifter
([
AveragePoolGrad
])
@op_lifter
([
AveragePoolGrad
])
def
local_avg_pool_dnn_grad_stride
(
node
,
ctx_name
):
def
local_avg_pool_dnn_grad_stride
(
node
,
ctx_name
):
if
not
dnn_available
(
ctx_name
):
if
not
dnn_available
(
ctx_name
):
r
eturn
r
aise_no_cudnn
()
if
not
node
.
op
.
ignore_border
:
if
not
node
.
op
.
ignore_border
:
return
return
inp
,
out_grad
=
node
.
inputs
inp
,
out_grad
=
node
.
inputs
...
@@ -1468,7 +1474,7 @@ def local_avg_pool_dnn_grad_stride(node, ctx_name):
...
@@ -1468,7 +1474,7 @@ def local_avg_pool_dnn_grad_stride(node, ctx_name):
def
local_softmax_dnn
(
node
):
def
local_softmax_dnn
(
node
):
if
isinstance
(
node
.
op
,
GpuSoftmax
):
if
isinstance
(
node
.
op
,
GpuSoftmax
):
if
not
dnn_available
(
node
.
outputs
[
0
]
.
type
.
context_name
):
if
not
dnn_available
(
node
.
outputs
[
0
]
.
type
.
context_name
):
r
eturn
r
aise_no_cudnn
()
ins
=
node
.
inputs
[
0
]
.
dimshuffle
(
0
,
1
,
'x'
,
'x'
)
ins
=
node
.
inputs
[
0
]
.
dimshuffle
(
0
,
1
,
'x'
,
'x'
)
ins
=
gpu_contiguous
(
ins
)
ins
=
gpu_contiguous
(
ins
)
out
=
GpuDnnSoftmax
(
'accurate'
,
'channel'
)(
ins
)
out
=
GpuDnnSoftmax
(
'accurate'
,
'channel'
)(
ins
)
...
@@ -1498,7 +1504,7 @@ def local_log_softmax_dnn(node):
...
@@ -1498,7 +1504,7 @@ def local_log_softmax_dnn(node):
def
local_logsoftmax_to_dnn
(
node
,
ctx_name
):
def
local_logsoftmax_to_dnn
(
node
,
ctx_name
):
if
not
dnn_available
(
ctx_name
)
or
version
()
<
3000
:
if
not
dnn_available
(
ctx_name
)
or
version
()
<
3000
:
# No log-softmax before cudnn v3
# No log-softmax before cudnn v3
r
eturn
r
aise_no_cudnn
(
"Need CuDNN v3 for LogSoftmax"
)
# Transform the input in the format expected by GpuDnnSoftmax
# Transform the input in the format expected by GpuDnnSoftmax
inp
=
node
.
inputs
[
0
]
inp
=
node
.
inputs
[
0
]
...
@@ -1534,7 +1540,7 @@ gpu_seqopt.register("NoCuDNNRaise", NoCuDNNRaise(), 0, 'cudnn')
...
@@ -1534,7 +1540,7 @@ gpu_seqopt.register("NoCuDNNRaise", NoCuDNNRaise(), 0, 'cudnn')
@op_lifter
([
SoftmaxGrad
])
@op_lifter
([
SoftmaxGrad
])
def
local_softmax_dnn_grad
(
node
,
ctx_name
):
def
local_softmax_dnn_grad
(
node
,
ctx_name
):
if
not
dnn_available
(
ctx_name
):
if
not
dnn_available
(
ctx_name
):
r
eturn
r
aise_no_cudnn
(
"CuDNN needed for SoftmaxGrad"
)
ins
=
[]
ins
=
[]
for
n
in
node
.
inputs
:
for
n
in
node
.
inputs
:
n
=
as_gpuarray_variable
(
n
,
ctx_name
)
n
=
as_gpuarray_variable
(
n
,
ctx_name
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论