Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d4625800
提交
d4625800
authored
6月 13, 2016
作者:
sentient07
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Made few opts accept outputs
上级
1b1a8505
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
17 行删除
+28
-17
dnn.py
theano/gpuarray/dnn.py
+10
-3
opt.py
theano/gpuarray/opt.py
+18
-14
没有找到文件。
theano/gpuarray/dnn.py
浏览文件 @
d4625800
...
...
@@ -1389,7 +1389,7 @@ class GpuDnnSoftmaxGrad(GpuDnnSoftmaxBase):
AbstractConv2d_gradInputs
])
@register_opt2
([
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
],
'fast_compile'
)
def
local_abstractconv_cudnn
(
op
,
context_name
,
inputs
):
def
local_abstractconv_cudnn
_graph
(
op
,
context_name
,
inputs
):
if
(
not
isinstance
(
op
,
(
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
))):
...
...
@@ -1434,8 +1434,15 @@ def local_abstractconv_cudnn(op, context_name, inputs):
conv_mode
=
conv_mode
)
return
[
rval
]
conv_groupopt
.
register
(
'local_abstractconv_cudnn'
,
local_abstractconv_cudnn
,
20
,
@local_optimizer
([
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
])
def
local_abstractconv_cudnn
(
node
):
ctx
=
infer_context
(
*
node
.
inputs
)
return
local_abstractconv_dnn_graph
(
node
.
op
,
ctx
,
node
.
inputs
)
conv_groupopt
.
register
(
'local_abstractconv_cudnn_graph'
,
local_abstractconv_cudnn_graph
,
20
,
'fast_compile'
,
'fast_run'
,
'gpuarray'
,
'conv_dnn'
,
'cudnn'
)
...
...
theano/gpuarray/opt.py
浏览文件 @
d4625800
...
...
@@ -168,9 +168,6 @@ def op_lifter(OP, cuda_only=False):
replace
=
True
break
clients
=
[
c
for
o
in
node
.
outputs
for
c
in
o
.
clients
]
# list of list containing clients
# it is clients per node basis
out_clients
=
[
o
.
clients
for
o
in
node
.
outputs
]
if
not
replace
:
# We replace if *all* clients are on the GPU
...
...
@@ -198,7 +195,9 @@ def op_lifter(OP, cuda_only=False):
try
:
new_op
=
maker
(
node
.
op
,
context_name
,
node
.
inputs
)
except
TypeError
:
new_op
=
maker
(
node
.
op
,
context_name
,
node
.
inputs
,
out_clients
)
# Pass the outputs so that the Local Optimizers don't need to
# build the nodes again.
new_op
=
maker
(
node
.
op
,
context_name
,
node
.
inputs
,
node
.
outputs
)
# This is needed as sometimes new_op inherits from OP.
if
new_op
and
new_op
!=
node
.
op
:
if
isinstance
(
new_op
,
theano
.
Op
):
...
...
@@ -357,7 +356,7 @@ class GraphToGPU(NavigatorOptimizer):
except
TypeError
:
new_ops
=
lopt
.
transform
(
node
.
op
,
context_name
,
[
mapping
[
i
]
for
i
in
node
.
inputs
],
out_clien
ts
)
node
.
outpu
ts
)
finally
:
time_opts
[
lopt
]
+=
time
.
time
()
-
t_opt
self
.
new_opts
.
append
(
lopt
)
...
...
@@ -417,6 +416,10 @@ class GraphToGPU(NavigatorOptimizer):
print
(
blanc
,
" time in local optimizers
%.3
fs"
%
s
,
file
=
stream
)
# print time per each optimizer
for
o
in
opt
.
new_opts
:
print
(
blanc
,
"Local Optimizer :"
+
str
(
o
)
+
" takes time :
%.3
f"
%
time_opts
[
o
],
file
=
stream
)
count_opt
=
[]
not_used
=
[]
not_used_time
=
0
...
...
@@ -678,13 +681,12 @@ def local_gpuflatten(op, context_name, inputs):
@register_opt
(
'fast_compile'
)
@op_lifter
([
tensor
.
Elemwise
])
@register_opt2
([
tensor
.
Elemwise
],
'fast_compile'
)
def
local_gpu_elemwise
(
op
,
context_name
,
inputs
):
def
local_gpu_elemwise
(
op
,
context_name
,
inputs
,
outputs
):
scal_op
=
op
.
scalar_op
name
=
op
.
name
node
=
op
.
make_node
(
*
inputs
)
if
name
:
name
=
'Gpu'
+
name
if
len
(
node
.
outputs
)
>
1
:
if
len
(
outputs
)
>
1
:
return
res
=
GpuElemwise
(
scal_op
,
name
=
name
,
inplace_pattern
=
copy
.
copy
(
op
.
inplace_pattern
),
...
...
@@ -697,7 +699,7 @@ def local_gpu_elemwise(op, context_name, inputs):
# Only transfer the computation on the gpu if the output dtype is
# floating point. Else, give up on the transfer to the gpu.
out_dtype
=
node
.
outputs
[
0
]
.
dtype
out_dtype
=
outputs
[
0
]
.
dtype
if
out_dtype
not
in
[
'float16'
,
'float32'
,
'float64'
]:
return
...
...
@@ -905,8 +907,11 @@ def local_gpua_split(op, context_name, inputs):
@register_opt
(
'fast_compile'
)
@op_lifter
([
tensor
.
Subtensor
])
@register_opt2
([
tensor
.
Subtensor
],
'fast_compile'
)
def
local_gpua_subtensor
(
op
,
context_name
,
inputs
,
clien
ts
):
def
local_gpua_subtensor
(
op
,
context_name
,
inputs
,
outpu
ts
):
x
=
inputs
[
0
]
# list of list containing clients
# it is clients per node basis
clients
=
[
o
.
clients
for
o
in
outputs
]
if
(
x
.
owner
and
isinstance
(
x
.
owner
.
op
,
HostFromGpu
)):
gpu_x
=
x
.
owner
.
inputs
[
0
]
if
(
gpu_x
.
owner
and
...
...
@@ -985,11 +990,10 @@ def local_advincsub1_gpua_inplace(node):
@register_opt
(
'fast_compile'
)
@op_lifter
([
tensor
.
CAReduce
,
tensor
.
Sum
,
tensor
.
elemwise
.
Prod
])
@register_opt2
([
tensor
.
CAReduce
,
tensor
.
Sum
,
tensor
.
elemwise
.
Prod
],
'fast_compile'
)
def
local_gpua_careduce
(
op
,
context_name
,
inputs
):
def
local_gpua_careduce
(
op
,
context_name
,
inputs
,
outputs
):
if
isinstance
(
op
.
scalar_op
,
(
scalar
.
Add
,
scalar
.
Mul
,
scalar
.
Maximum
,
scalar
.
Minimum
)):
node
=
op
.
make_node
(
*
inputs
)
ctx
=
get_context
(
context_name
)
if
ctx
.
kind
==
b
'opencl'
:
op2
=
GpuCAReduceCPY
...
...
@@ -1056,10 +1060,10 @@ def local_gpua_careduce(op, context_name, inputs):
reduce_reshaped_x
=
host_from_gpu
(
greduce
(
gpu_reshaped_x
))
if
reduce_reshaped_x
.
ndim
!=
node
.
outputs
[
0
]
.
ndim
:
if
reduce_reshaped_x
.
ndim
!=
outputs
[
0
]
.
ndim
:
out_shp
=
[]
for
i
in
range
(
x
.
ndim
):
if
i
not
in
node
.
op
.
axis
:
if
i
not
in
op
.
axis
:
out_shp
.
append
(
shape_i
(
x
,
i
))
unreshaped_reduce
=
reduce_reshaped_x
.
reshape
(
tensor
.
stack
(
out_shp
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论