Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0ad57e82
提交
0ad57e82
authored
9月 17, 2014
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for subsampling with GpuDnnConv and tests it and the gradient.
上级
211ee289
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
13 行增加
和
8 行删除
+13
-8
dnn.py
theano/sandbox/cuda/dnn.py
+13
-8
test_conv_cuda_ndarray.py
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
+0
-0
没有找到文件。
theano/sandbox/cuda/dnn.py
浏览文件 @
0ad57e82
...
@@ -12,6 +12,7 @@ from theano.sandbox.cuda.basic_ops import (as_cuda_ndarray_variable,
...
@@ -12,6 +12,7 @@ from theano.sandbox.cuda.basic_ops import (as_cuda_ndarray_variable,
from
theano.sandbox.cuda.blas
import
GpuConv
from
theano.sandbox.cuda.blas
import
GpuConv
from
theano.compat
import
PY3
from
theano.compat
import
PY3
class
DnnBase
(
GpuOp
):
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.
...
@@ -46,11 +47,12 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
...
@@ -46,11 +47,12 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
class
GpuDnnConvBase
(
DnnBase
):
class
GpuDnnConvBase
(
DnnBase
):
__props__
=
(
'border_mode'
,
'conv_mode'
)
__props__
=
(
'border_mode'
,
'
subsample'
,
'
conv_mode'
)
def
__init__
(
self
,
border_mode
,
conv_mode
=
'conv'
):
def
__init__
(
self
,
border_mode
,
subsample
=
(
1
,
1
),
conv_mode
=
'conv'
):
assert
border_mode
in
(
'valid'
,
'full'
)
assert
border_mode
in
(
'valid'
,
'full'
)
self
.
border_mode
=
border_mode
self
.
border_mode
=
border_mode
self
.
subsample
=
subsample
assert
conv_mode
in
(
'conv'
,
'cross'
)
assert
conv_mode
in
(
'conv'
,
'cross'
)
self
.
conv_mode
=
conv_mode
self
.
conv_mode
=
conv_mode
...
@@ -58,6 +60,8 @@ class GpuDnnConvBase(DnnBase):
...
@@ -58,6 +60,8 @@ class GpuDnnConvBase(DnnBase):
self
.
__dict__
.
update
(
props
)
self
.
__dict__
.
update
(
props
)
if
not
hasattr
(
self
,
'conv_mode'
):
if
not
hasattr
(
self
,
'conv_mode'
):
self
.
conv_mode
=
'conv'
self
.
conv_mode
=
'conv'
if
not
hasattr
(
self
,
'subsample'
):
self
.
subsample
=
(
1
,
1
)
def
make_node
(
self
,
img
,
kern
):
def
make_node
(
self
,
img
,
kern
):
if
img
.
type
.
ndim
!=
4
:
if
img
.
type
.
ndim
!=
4
:
...
@@ -209,7 +213,7 @@ err%(name)s = cudnnSetConvolutionDescriptor(
...
@@ -209,7 +213,7 @@ err%(name)s = cudnnSetConvolutionDescriptor(
op
%(id)
d, param0_
%(id)
d, param1_
%(id)
d,
op
%(id)
d, param0_
%(id)
d, param1_
%(id)
d,
pad_h
%(name)
s,
pad_h
%(name)
s,
pad_w
%(name)
s,
pad_w
%(name)
s,
1, 1
, 1, 1,
%(subsx)
d,
%(subsy)
d
, 1, 1,
%(conv_flag)
s
%(conv_flag)
s
);
);
if (err
%(name)
s != CUDNN_STATUS_SUCCESS) {
if (err
%(name)
s != CUDNN_STATUS_SUCCESS) {
...
@@ -252,10 +256,11 @@ if (err%(name)s != CUDNN_STATUS_SUCCESS) {
...
@@ -252,10 +256,11 @@ if (err%(name)s != CUDNN_STATUS_SUCCESS) {
"""
%
dict
(
param0
=
param0
,
param1
=
param1
,
out
=
out
,
bmode
=
bmode
,
"""
%
dict
(
param0
=
param0
,
param1
=
param1
,
out
=
out
,
bmode
=
bmode
,
conv_flag
=
conv_flag
,
fail
=
sub
[
'fail'
],
id
=
sub
[
'struct_id'
],
conv_flag
=
conv_flag
,
fail
=
sub
[
'fail'
],
id
=
sub
[
'struct_id'
],
name
=
name
,
checks
=
'
\n
'
.
join
(
checks
),
sets
=
'
\n
'
.
join
(
sets
),
name
=
name
,
checks
=
'
\n
'
.
join
(
checks
),
sets
=
'
\n
'
.
join
(
sets
),
subsx
=
self
.
subsample
[
0
],
subsy
=
self
.
subsample
[
1
],
set_out
=
set_out
,
method
=
self
.
conv_op
,
path
=
self
.
path_flag
)
set_out
=
set_out
,
method
=
self
.
conv_op
,
path
=
self
.
path_flag
)
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
5
,)
return
(
6
,)
class
GpuDnnConv
(
GpuDnnConvBase
):
class
GpuDnnConv
(
GpuDnnConvBase
):
...
@@ -291,12 +296,12 @@ from theano.sandbox.cuda.opt import (local_optimizer, gpu_contiguous,
...
@@ -291,12 +296,12 @@ from theano.sandbox.cuda.opt import (local_optimizer, gpu_contiguous,
@local_optimizer
([
GpuConv
])
@local_optimizer
([
GpuConv
])
def
local_conv_dnn
(
node
):
def
local_conv_dnn
(
node
):
if
isinstance
(
node
.
op
,
GpuConv
):
if
isinstance
(
node
.
op
,
GpuConv
):
if
(
node
.
op
.
subsample
!=
(
1
,
1
)
or
if
node
.
op
.
border_mode
not
in
[
'full'
,
'valid'
]:
node
.
op
.
border_mode
not
in
[
'full'
,
'valid'
]):
return
return
img
,
kern
=
node
.
inputs
img
,
kern
=
node
.
inputs
border_mode
=
node
.
op
.
border_mode
border_mode
=
node
.
op
.
border_mode
return
[
GpuDnnConv
(
border_mode
)(
gpu_contiguous
(
img
),
subsample
=
node
.
op
.
subsample
gpu_contiguous
(
kern
))]
return
[
GpuDnnConv
(
border_mode
,
subsample
)(
gpu_contiguous
(
img
),
gpu_contiguous
(
kern
))]
gpu_optimizer
.
register
(
"conv_cudnn"
,
local_conv_dnn
,
'cudnn'
)
gpu_optimizer
.
register
(
"conv_cudnn"
,
local_conv_dnn
,
'cudnn'
)
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
浏览文件 @
0ad57e82
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论