Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a90c7e81
提交
a90c7e81
authored
6月 09, 2016
作者:
sentient07
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added new optimizer to local_abstractconv_cudnn
上级
3c5c1506
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
23 行删除
+27
-23
dnn.py
theano/gpuarray/dnn.py
+19
-17
extra_ops.py
theano/gpuarray/extra_ops.py
+5
-5
opt.py
theano/gpuarray/opt.py
+3
-1
没有找到文件。
theano/gpuarray/dnn.py
浏览文件 @
a90c7e81
...
@@ -1384,14 +1384,16 @@ class GpuDnnSoftmaxGrad(GpuDnnSoftmaxBase):
...
@@ -1384,14 +1384,16 @@ class GpuDnnSoftmaxGrad(GpuDnnSoftmaxBase):
@local_optimizer
([
AbstractConv2d
,
AbstractConv2d_gradWeights
,
@local_optimizer
([
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
])
AbstractConv2d_gradInputs
])
def
local_abstractconv_cudnn
(
node
):
@register_opt2
([
AbstractConv2d
,
AbstractConv2d_gradWeights
,
if
(
not
isinstance
(
node
.
op
,
(
AbstractConv2d
,
AbstractConv2d_gradInputs
],
'fast_compile'
)
def
local_abstractconv_cudnn
(
op
,
context_name
,
inputs
):
if
(
not
isinstance
(
op
,
(
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
))):
AbstractConv2d_gradInputs
))):
return
None
return
None
inp1
=
node
.
inputs
[
0
]
inp1
=
inputs
[
0
]
inp2
=
node
.
inputs
[
1
]
inp2
=
inputs
[
1
]
if
(
node
.
op
.
filter_dilation
!=
(
1
,
1
)):
if
(
node
.
op
.
filter_dilation
!=
(
1
,
1
)):
return
None
return
None
...
@@ -1402,30 +1404,30 @@ def local_abstractconv_cudnn(node):
...
@@ -1402,30 +1404,30 @@ def local_abstractconv_cudnn(node):
if
not
dnn_available
(
inp1
.
type
.
context_name
):
if
not
dnn_available
(
inp1
.
type
.
context_name
):
raise_no_cudnn
()
raise_no_cudnn
()
if
node
.
op
.
filter_flip
:
if
op
.
filter_flip
:
conv_mode
=
'conv'
conv_mode
=
'conv'
else
:
else
:
conv_mode
=
'cross'
conv_mode
=
'cross'
if
isinstance
(
node
.
op
,
AbstractConv2d
):
if
isinstance
(
op
,
AbstractConv2d
):
rval
=
dnn_conv
(
inp1
,
inp2
,
rval
=
dnn_conv
(
inp1
,
inp2
,
border_mode
=
node
.
op
.
border_mode
,
border_mode
=
op
.
border_mode
,
subsample
=
node
.
op
.
subsample
,
subsample
=
op
.
subsample
,
direction_hint
=
'forward!'
,
direction_hint
=
'forward!'
,
conv_mode
=
conv_mode
)
conv_mode
=
conv_mode
)
if
isinstance
(
node
.
op
,
AbstractConv2d_gradWeights
):
if
isinstance
(
op
,
AbstractConv2d_gradWeights
):
shape
=
(
inp2
.
shape
[
1
],
inp1
.
shape
[
1
],
shape
=
(
inp2
.
shape
[
1
],
inp1
.
shape
[
1
],
node
.
inputs
[
2
][
0
],
node
.
inputs
[
2
][
1
])
inputs
[
2
][
0
],
inputs
[
2
][
1
])
rval
=
dnn_gradweight
(
inp1
,
inp2
,
shape
,
rval
=
dnn_gradweight
(
inp1
,
inp2
,
shape
,
border_mode
=
node
.
op
.
border_mode
,
border_mode
=
op
.
border_mode
,
subsample
=
node
.
op
.
subsample
,
subsample
=
op
.
subsample
,
conv_mode
=
conv_mode
)
conv_mode
=
conv_mode
)
if
isinstance
(
node
.
op
,
AbstractConv2d_gradInputs
):
if
isinstance
(
op
,
AbstractConv2d_gradInputs
):
shape
=
(
inp2
.
shape
[
0
],
inp1
.
shape
[
1
],
shape
=
(
inp2
.
shape
[
0
],
inp1
.
shape
[
1
],
node
.
inputs
[
2
][
0
],
node
.
inputs
[
2
][
1
])
inputs
[
2
][
0
],
inputs
[
2
][
1
])
rval
=
dnn_gradinput
(
inp1
,
inp2
,
shape
,
rval
=
dnn_gradinput
(
inp1
,
inp2
,
shape
,
border_mode
=
node
.
op
.
border_mode
,
border_mode
=
op
.
border_mode
,
subsample
=
node
.
op
.
subsample
,
subsample
=
op
.
subsample
,
conv_mode
=
conv_mode
)
conv_mode
=
conv_mode
)
return
[
rval
]
return
[
rval
]
...
@@ -1633,7 +1635,7 @@ gpu_seqopt.register("NoCuDNNRaise", NoCuDNNRaise(), 0, 'cudnn')
...
@@ -1633,7 +1635,7 @@ gpu_seqopt.register("NoCuDNNRaise", NoCuDNNRaise(), 0, 'cudnn')
@register_opt
(
'cudnn'
,
'fast_compile'
)
@register_opt
(
'cudnn'
,
'fast_compile'
)
@op_lifter
([
SoftmaxGrad
])
@op_lifter
([
SoftmaxGrad
])
#@register_opt2([SoftmaxGrad]
, 'fast_compile')
@register_opt2
([
SoftmaxGrad
],
'cudnn'
,
'fast_compile'
)
def
local_softmax_dnn_grad
(
op
,
ctx_name
,
inputs
):
def
local_softmax_dnn_grad
(
op
,
ctx_name
,
inputs
):
if
not
dnn_available
(
ctx_name
):
if
not
dnn_available
(
ctx_name
):
raise_no_cudnn
(
"cuDNN needed for SoftmaxGrad"
)
raise_no_cudnn
(
"cuDNN needed for SoftmaxGrad"
)
...
...
theano/gpuarray/extra_ops.py
浏览文件 @
a90c7e81
...
@@ -452,8 +452,8 @@ class GpuCumsum(GpuKernelBase, Op):
...
@@ -452,8 +452,8 @@ class GpuCumsum(GpuKernelBase, Op):
@register_opt
(
'fast_compile'
)
@register_opt
(
'fast_compile'
)
@op_lifter
([
CumsumOp
])
@op_lifter
([
CumsumOp
])
@register_opt2
([
CumsumOp
],
'fast_compile'
)
#
@register_opt2([CumsumOp], 'fast_compile')
def
use_gpu_cumsumop
(
op
,
ctx_name
,
inputs
):
def
use_gpu_cumsumop
(
op
,
ctx_name
,
inputs
,
):
if
inputs
[
0
]
.
dtype
==
'float32'
:
if
inputs
[
0
]
.
dtype
==
'float32'
:
axis
=
op
.
axis
axis
=
op
.
axis
x
=
inputs
[
0
]
x
=
inputs
[
0
]
...
@@ -464,7 +464,7 @@ def use_gpu_cumsumop(op, ctx_name, inputs):
...
@@ -464,7 +464,7 @@ def use_gpu_cumsumop(op, ctx_name, inputs):
if
axis
is
None
and
x
.
ndim
>
1
:
if
axis
is
None
and
x
.
ndim
>
1
:
x
=
x
.
flatten
()
x
=
x
.
flatten
()
x
=
GpuFromHost
(
ctx_name
)(
x
)
x
=
as_gpuarray_variable
(
x
,
ctx_name
)
# ``gpu_cumsum`` assume array has been flattened if needed.
# ``gpu_cumsum`` assume array has been flattened if needed.
if
axis
is
None
:
if
axis
is
None
:
...
@@ -473,4 +473,4 @@ def use_gpu_cumsumop(op, ctx_name, inputs):
...
@@ -473,4 +473,4 @@ def use_gpu_cumsumop(op, ctx_name, inputs):
return
GpuCumsum
(
axis
)(
x
)
return
GpuCumsum
(
axis
)(
x
)
#register_opt('fast_compile')(use_gpu_cumsumop)
#register_opt('fast_compile')(use_gpu_cumsumop)
#register_opt2([CumsumOp], 'fast_compile')(use_gpu_cumsumop)
#
\ No newline at end of file
\ No newline at end of file
theano/gpuarray/opt.py
浏览文件 @
a90c7e81
...
@@ -282,14 +282,16 @@ class GraphToGPU(Optimizer):
...
@@ -282,14 +282,16 @@ class GraphToGPU(Optimizer):
continue
continue
# Move only if any of the inputs are on the GPU.
# Move only if any of the inputs are on the GPU.
move_to_GPU
=
Fals
e
move_to_GPU
=
Tru
e
'''
if any([isinstance(i, GpuArrayVariable) or
if any([isinstance(i, GpuArrayVariable) or
isinstance(i, GpuArraySharedVariable)
isinstance(i, GpuArraySharedVariable)
for i in [mapping[v] for v in node.inputs] +
for i in [mapping[v] for v in node.inputs] +
node.outputs]):
node.outputs]):
move_to_GPU = True
move_to_GPU = True
'''
out_clients
=
[
o
.
clients
for
o
in
node
.
outputs
]
out_clients
=
[
o
.
clients
for
o
in
node
.
outputs
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论