Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
29024484
提交
29024484
authored
11月 14, 2014
作者:
f0k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Slightly cleaned up registration of GPU convolution optimizers and corresponding tags
上级
ea9e3e54
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
33 行删除
+29
-33
dnn.py
theano/sandbox/cuda/dnn.py
+1
-1
opt.py
theano/sandbox/cuda/opt.py
+28
-32
没有找到文件。
theano/sandbox/cuda/dnn.py
浏览文件 @
29024484
...
@@ -1087,7 +1087,7 @@ if cuda_available:
...
@@ -1087,7 +1087,7 @@ if cuda_available:
from
theano.sandbox.cuda.opt
import
(
from
theano.sandbox.cuda.opt
import
(
local_optimizer
,
gpu_optimizer
,
gpu_seqopt
)
local_optimizer
,
gpu_optimizer
,
gpu_seqopt
)
@register_opt
(
'cudnn'
)
#@register_opt('cudnn') # this optimizer is registered in opt.py instead.
@local_optimizer
([
GpuConv
])
@local_optimizer
([
GpuConv
])
def
local_conv_dnn
(
node
):
def
local_conv_dnn
(
node
):
if
not
dnn_available
():
if
not
dnn_available
():
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
29024484
...
@@ -1105,12 +1105,9 @@ def local_gpu_softmax_with_bias(node):
...
@@ -1105,12 +1105,9 @@ def local_gpu_softmax_with_bias(node):
return
[
host_from_gpu
(
gpu_sm
)]
return
[
host_from_gpu
(
gpu_sm
)]
return
False
return
False
# Convolution, maxpooling
# Convolution
from
theano.tensor.nnet
import
conv
from
theano.tensor.nnet
import
conv
# We need a fixed order for the user interface.
conv_groupopt
=
theano
.
gof
.
optdb
.
LocalGroupDB
()
conv_groupopt
.
__name__
=
"gpu_conv_opts"
register_opt
(
'fast_compile'
,
'fast_run'
,
'gpu'
)(
conv_groupopt
)
def
_gpu_conv_to_fftconv
(
node
):
def
_gpu_conv_to_fftconv
(
node
):
...
@@ -1163,22 +1160,8 @@ def local_conv_fft_full(node):
...
@@ -1163,22 +1160,8 @@ def local_conv_fft_full(node):
return
return
@local_optimizer
([
GpuConv
])
def
local_gpu_conv
(
node
):
"""
If cudnn is available, use it. Otherwise, use the gemm version.
"""
if
(
isinstance
(
node
.
op
,
GpuConv
)
and
theano
.
sandbox
.
cuda
.
dnn
.
dnn_available
()):
return
theano
.
sandbox
.
cuda
.
dnn
.
local_conv_dnn
.
transform
(
node
)
# If dnn isn't avail, the local_gpu_conv_legacy wil introduce the
# legacy opt. Then the local_conv_gemm will convert it to gemm
# opt.
@local_optimizer
([
gpu_from_host
,
conv
.
ConvOp
])
@local_optimizer
([
gpu_from_host
,
conv
.
ConvOp
])
def
local_gpu_conv
_legacy
(
node
):
def
local_gpu_conv
(
node
):
"""
"""
gpu_from_host(conv) -> gpu_conv(gpu_from_host)
gpu_from_host(conv) -> gpu_conv(gpu_from_host)
...
@@ -1334,19 +1317,31 @@ def local_conv_gemm(node):
...
@@ -1334,19 +1317,31 @@ def local_conv_gemm(node):
gpu_contiguous
(
kern
),
gpu_contiguous
(
img
))]
gpu_contiguous
(
kern
),
gpu_contiguous
(
img
))]
# Legacy opt first, as this is the only that move to the GPU.
# First we register the optimizer that moves convolutions to the GPU.
# Then fft, as disabled dy default. So if use enable it, it have prio
register_opt
()(
local_gpu_conv
)
# Then default, use dnn if avail
# Then default, use gemm if dnn or fft didn't worked.
# Then we create a group of optimizers that replace the legacy GpuConv
# Normally, gemm should catch all case, so the legacy should never run.
# with other implementations. They are tried in a specific order so we
conv_groupopt
.
register
(
'local_gpu_conv_legacy'
,
local_gpu_conv_legacy
,
0
,
# can control which ones take precedence over others.
'fast_compile'
,
'fast_run'
)
conv_groupopt
=
theano
.
gof
.
optdb
.
LocalGroupDB
()
conv_groupopt
.
register
(
"conv_fft_valid"
,
local_conv_fft_valid
,
1
)
conv_groupopt
.
__name__
=
"gpu_conv_opts"
conv_groupopt
.
register
(
"conv_fft_full"
,
local_conv_fft_full
,
1
)
register_opt
()(
conv_groupopt
)
# Use dnn if avail, so have the dnn tag to be able to disable it.
conv_groupopt
.
register
(
'local_gpu_conv'
,
local_gpu_conv
,
10
,
# FFT gets the highest priority (lowest number), but is disabled by default.
# It can be enabled by including 'conv_fft'.
conv_groupopt
.
register
(
'conv_fft_valid'
,
local_conv_fft_valid
,
10
,
'conv_fft'
)
conv_groupopt
.
register
(
'conv_fft_full'
,
local_conv_fft_full
,
10
,
'conv_fft'
)
# cuDNN is the second, but only registered if cuDNN is available.
# It can be disabled by excluding 'conv_dnn' or 'cudnn'.
from
.
import
dnn
if
dnn
.
dnn_available
():
conv_groupopt
.
register
(
'conv_dnn'
,
dnn
.
local_conv_dnn
,
20
,
'fast_compile'
,
'fast_run'
,
'cudnn'
)
'fast_compile'
,
'fast_run'
,
'cudnn'
)
conv_groupopt
.
register
(
'local_conv_gemm'
,
local_conv_gemm
,
12
,
# The GEMM-based convolution comes last to catch all remaining cases.
# It can be disabled by excluding 'conv_gemm'.
conv_groupopt
.
register
(
'conv_gemm'
,
local_conv_gemm
,
30
,
'fast_compile'
,
'fast_run'
)
'fast_compile'
,
'fast_run'
)
...
@@ -1500,6 +1495,7 @@ def local_convtransp3d_gemm(node):
...
@@ -1500,6 +1495,7 @@ def local_convtransp3d_gemm(node):
gpu_optimizer
.
register
(
"convtransp3d_gemm"
,
local_convtransp3d_gemm
)
gpu_optimizer
.
register
(
"convtransp3d_gemm"
,
local_convtransp3d_gemm
)
# Pooling
import
theano.tensor.signal.downsample
as
downsample
import
theano.tensor.signal.downsample
as
downsample
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论