Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
136153f4
提交
136153f4
authored
10月 09, 2015
作者:
Nicolas Ballas
提交者:
Pascal Lamblin
10月 14, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update optim
上级
24b77b44
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
42 行增加
和
23 行删除
+42
-23
dnn.py
theano/sandbox/cuda/dnn.py
+1
-3
opt.py
theano/sandbox/cuda/opt.py
+35
-11
abstract_conv2d.py
theano/tensor/nnet/abstract_conv2d.py
+6
-9
没有找到文件。
theano/sandbox/cuda/dnn.py
浏览文件 @
136153f4
...
@@ -2451,8 +2451,7 @@ if True:
...
@@ -2451,8 +2451,7 @@ if True:
### AbstractConv Optimizations
### AbstractConv Optimizations
@local_optimizer
([
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
])
@local_optimizer
([
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
])
def
local_conv2d_cudnn
(
node
):
def
local_abstractconv_cudnn
(
node
):
inp1
=
node
.
inputs
[
0
]
inp1
=
node
.
inputs
[
0
]
inp2
=
node
.
inputs
[
1
]
inp2
=
node
.
inputs
[
1
]
...
@@ -2487,5 +2486,4 @@ def local_conv2d_cudnn(node):
...
@@ -2487,5 +2486,4 @@ def local_conv2d_cudnn(node):
subsample
=
node
.
op
.
subsample
,
subsample
=
node
.
op
.
subsample
,
conv_mode
=
conv_mode
)
conv_mode
=
conv_mode
)
return
[
rval
]
return
[
rval
]
register_specialize_device
(
local_conv2d_cudnn
,
'cudnn'
)
theano/sandbox/cuda/opt.py
浏览文件 @
136153f4
...
@@ -2686,8 +2686,9 @@ register_opt()(local_conv2d_gpu_conv)
...
@@ -2686,8 +2686,9 @@ register_opt()(local_conv2d_gpu_conv)
### Corrmm opt
### Corrmm opt
@local_optimizer
([
AbstractConv2d
])
@local_optimizer
([
AbstractConv2d
])
def
local_conv2d_corrmm
(
node
):
def
local_abstractconv_gemm
(
node
):
if
not
isinstance
(
node
.
op
,
AbstractConv2d
):
return
None
img
,
kern
=
node
.
inputs
img
,
kern
=
node
.
inputs
if
(
not
isinstance
(
img
.
type
,
CudaNdarrayType
)
or
if
(
not
isinstance
(
img
.
type
,
CudaNdarrayType
)
or
not
isinstance
(
kern
.
type
,
CudaNdarrayType
)):
not
isinstance
(
kern
.
type
,
CudaNdarrayType
)):
...
@@ -2743,16 +2744,15 @@ def local_conv2d_corrmm(node):
...
@@ -2743,16 +2744,15 @@ def local_conv2d_corrmm(node):
)
.
dimshuffle
(
1
,
0
,
2
,
3
))
)
.
dimshuffle
(
1
,
0
,
2
,
3
))
return
[
rval
]
return
[
rval
]
register_specialize_device
(
local_conv2d_corrmm
,
'conv_gemm'
)
@local_optimizer
([
AbstractConv2d_gradWeights
])
@local_optimizer
([
AbstractConv2d_gradWeights
])
def
local_conv2d_gradweight_corrmm
(
node
):
def
local_abstractconv_gradweight_gemm
(
node
):
if
not
isinstance
(
node
.
op
,
AbstractConv2d_gradWeights
):
return
None
img
,
topgrad
,
shape
=
node
.
inputs
img
,
topgrad
,
shape
=
node
.
inputs
if
not
isinstance
(
img
.
type
,
CudaNdarrayType
)
or
\
if
not
isinstance
(
img
.
type
,
CudaNdarrayType
)
or
\
not
isinstance
(
topgrad
.
type
,
CudaNdarrayType
):
not
isinstance
(
topgrad
.
type
,
CudaNdarrayType
):
return
None
return
None
rval
=
GpuCorrMM_gradWeights
(
border_mode
=
node
.
op
.
border_mode
,
rval
=
GpuCorrMM_gradWeights
(
border_mode
=
node
.
op
.
border_mode
,
subsample
=
node
.
op
.
subsample
)(
subsample
=
node
.
op
.
subsample
)(
gpu_contiguous
(
img
),
gpu_contiguous
(
topgrad
),
shape
)
gpu_contiguous
(
img
),
gpu_contiguous
(
topgrad
),
shape
)
...
@@ -2761,12 +2761,12 @@ def local_conv2d_gradweight_corrmm(node):
...
@@ -2761,12 +2761,12 @@ def local_conv2d_gradweight_corrmm(node):
rval
=
tensor
.
patternbroadcast
(
rval
,
node
.
outputs
[
0
]
.
broadcastable
)
rval
=
tensor
.
patternbroadcast
(
rval
,
node
.
outputs
[
0
]
.
broadcastable
)
rval
=
as_cuda_ndarray_variable
(
rval
)
rval
=
as_cuda_ndarray_variable
(
rval
)
return
[
rval
]
return
[
rval
]
register_specialize_device
(
local_conv2d_gradweight_corrmm
,
'conv_gemm'
)
@local_optimizer
([
AbstractConv2d_gradInputs
])
@local_optimizer
([
AbstractConv2d_gradInputs
])
def
local_conv2d_gradinputs_corrmm
(
node
):
def
local_abstractconv_gradinputs_gemm
(
node
):
if
not
isinstance
(
node
.
op
,
AbstractConv2d_gradInputs
):
return
None
kern
,
topgrad
,
shape
=
node
.
inputs
kern
,
topgrad
,
shape
=
node
.
inputs
if
not
isinstance
(
kern
.
type
,
CudaNdarrayType
)
or
\
if
not
isinstance
(
kern
.
type
,
CudaNdarrayType
)
or
\
not
isinstance
(
topgrad
.
type
,
CudaNdarrayType
):
not
isinstance
(
topgrad
.
type
,
CudaNdarrayType
):
return
None
return
None
...
@@ -2778,4 +2778,28 @@ def local_conv2d_gradinputs_corrmm(node):
...
@@ -2778,4 +2778,28 @@ def local_conv2d_gradinputs_corrmm(node):
subsample
=
node
.
op
.
subsample
)(
subsample
=
node
.
op
.
subsample
)(
gpu_contiguous
(
kern
),
gpu_contiguous
(
topgrad
),
shape
)
gpu_contiguous
(
kern
),
gpu_contiguous
(
topgrad
),
shape
)
return
[
rval
]
return
[
rval
]
register_specialize_device
(
local_conv2d_gradinputs_corrmm
,
'conv_gemm'
)
# Register GPU convolution implementation
# They are tried in a specific order so we can control
# which ones take precedence over others.
abstractconv_groupopt
=
theano
.
gof
.
optdb
.
LocalGroupDB
()
abstractconv_groupopt
.
__name__
=
"gpu_abstractconv_opts"
register_opt
()(
abstractconv_groupopt
)
# cuDNN is first, but only registered if cuDNN is available.
conv_groupopt
.
register
(
'local_abstractconv_dnn'
,
dnn
.
local_abstractconv_cudnn
,
20
,
'conv_dnn'
,
'fast_compile'
,
'fast_run'
,
'cudnn'
)
# The GEMM-based convolution comes last to catch all remaining cases.
# It can be disabled by excluding 'conv_gemm'.
conv_groupopt
.
register
(
'local_abstractconv_gemm'
,
local_abstractconv_gemm
,
30
,
'conv_gemm'
,
'fast_compile'
,
'fast_run'
)
conv_groupopt
.
register
(
'local_abstractconv_gradweight_gemm'
,
local_abstractconv_gradweight_gemm
,
30
,
#'conv_gemm',
'fast_compile'
,
'fast_run'
)
conv_groupopt
.
register
(
'local_abstractconv_gradinputs_gemm'
,
local_abstractconv_gradinputs_gemm
,
30
,
#'conv_gemm',
'fast_compile'
,
'fast_run'
)
theano/tensor/nnet/abstract_conv2d.py
浏览文件 @
136153f4
...
@@ -14,10 +14,7 @@ from theano.tensor import (as_tensor_variable, blas, get_scalar_constant_value,
...
@@ -14,10 +14,7 @@ from theano.tensor import (as_tensor_variable, blas, get_scalar_constant_value,
from
theano.tensor
import
TensorType
from
theano.tensor
import
TensorType
from
theano.gof
import
Apply
,
Op
from
theano.gof
import
Apply
,
Op
from
theano.gof
import
local_optimizer
from
theano.gof
import
local_optimizer
from
theano.tensor.opt
import
register_specialize_device
from
theano.tensor.opt
import
register_specialize_device
from
theano.sandbox.cuda.type
import
CudaNdarrayType
## Cpu implementation
## Cpu implementation
from
theano.tensor.nnet
import
conv2d
as
cpu_conv2d
,
ConvOp
from
theano.tensor.nnet
import
conv2d
as
cpu_conv2d
,
ConvOp
...
@@ -327,8 +324,8 @@ def local_conv2d_cpu(node):
...
@@ -327,8 +324,8 @@ def local_conv2d_cpu(node):
return
None
return
None
img
,
kern
=
node
.
inputs
img
,
kern
=
node
.
inputs
if
isinstance
(
img
.
type
,
CudaNdarrayType
)
or
\
if
(
not
isinstance
(
img
.
type
,
TensorType
)
or
isinstance
(
kern
.
type
,
CudaNdarrayType
):
not
isinstance
(
kern
.
type
,
TensorType
)
):
return
None
return
None
if
node
.
op
.
border_mode
not
in
[
'full'
,
'valid'
]:
if
node
.
op
.
border_mode
not
in
[
'full'
,
'valid'
]:
return
None
return
None
...
@@ -349,8 +346,8 @@ def local_conv2d_gradweight_cpu(node):
...
@@ -349,8 +346,8 @@ def local_conv2d_gradweight_cpu(node):
img
,
topgrad
,
shape
=
node
.
inputs
img
,
topgrad
,
shape
=
node
.
inputs
if
isinstance
(
img
.
type
,
CudaNdarrayType
)
or
\
if
(
not
isinstance
(
img
.
type
,
TensorType
)
or
isinstance
(
topgrad
.
type
,
CudaNdarrayType
):
not
isinstance
(
topgrad
.
type
,
TensorType
)
):
return
None
return
None
if
node
.
op
.
border_mode
not
in
[
'full'
,
'valid'
]:
if
node
.
op
.
border_mode
not
in
[
'full'
,
'valid'
]:
return
None
return
None
...
@@ -458,8 +455,8 @@ register_specialize_device(local_conv2d_gradweight_cpu)
...
@@ -458,8 +455,8 @@ register_specialize_device(local_conv2d_gradweight_cpu)
def
local_conv2d_gradinputs_cpu
(
node
):
def
local_conv2d_gradinputs_cpu
(
node
):
kern
,
topgrad
,
shape
=
node
.
inputs
kern
,
topgrad
,
shape
=
node
.
inputs
if
isinstance
(
kern
.
type
,
CudaNdarrayType
)
or
\
if
(
not
isinstance
(
kern
.
type
,
TensorType
)
or
isinstance
(
topgrad
.
type
,
CudaNdarrayType
):
not
isinstance
(
topgrad
.
type
,
TensorType
)
):
return
None
return
None
if
node
.
op
.
border_mode
not
in
[
'full'
,
'valid'
]:
if
node
.
op
.
border_mode
not
in
[
'full'
,
'valid'
]:
return
None
return
None
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论