Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9aa5cec7
提交
9aa5cec7
authored
6月 17, 2013
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimisation to replace Alloc nodes.
上级
54e3a06e
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
34 行增加
和
3 行删除
+34
-3
opt.py
theano/sandbox/gpuarray/opt.py
+34
-3
没有找到文件。
theano/sandbox/gpuarray/opt.py
浏览文件 @
9aa5cec7
...
@@ -74,9 +74,40 @@ def local_cut_gpu_host_gpu(node):
...
@@ -74,9 +74,40 @@ def local_cut_gpu_host_gpu(node):
return
[
node
.
inputs
[
0
]
.
owner
.
inputs
[
0
]]
return
[
node
.
inputs
[
0
]
.
owner
.
inputs
[
0
]]
return
False
return
False
gpu_cut_copies
.
register
(
'cut_gpu_host_transfers'
,
local_cut_gpu_host_gpu
,
gpu_cut_copies
.
register
(
'cut_gpu_host_transfers'
,
local_cut_gpu_host_gpu
,
'fast_run'
,
'inplace'
,
'gpu'
)
'fast_run'
,
'inplace'
,
'gpu
array
'
)
gpu_cut_copies
.
register
(
'cut_gpu_constant_transfers'
,
gpu_cut_copies
.
register
(
'cut_gpu_constant_transfers'
,
tensor
.
opt
.
constant_folding
,
tensor
.
opt
.
constant_folding
,
'fast_run'
,
'gpu'
)
'fast_run'
,
'gpu
array
'
)
optdb
[
'canonicalize'
]
.
register
(
'local_cut_gpu_host_gpu'
,
optdb
[
'canonicalize'
]
.
register
(
'local_cut_gpu_host_gpu'
,
local_cut_gpu_host_gpu
,
'fast_run'
,
'gpu'
)
local_cut_gpu_host_gpu
,
'fast_run'
,
'gpuarray'
)
@register_opt
()
@local_optimizer
([
tensor
.
Alloc
])
def
local_gpualloc
(
node
):
replace
=
False
if
node
.
op
==
tensor
.
alloc
:
if
node
.
inputs
[
0
]
.
owner
and
node
.
inputs
[
0
]
.
owner
.
op
==
host_from_gpu
:
replace
=
True
elif
all
([
c
!=
'output'
and
c
.
op
==
gpu_from_host
for
c
,
idx
in
node
.
outputs
[
0
]
.
clients
]):
replace
=
True
elif
all
([
c
!=
'output'
and
c
.
op
==
tensor
.
join
and
all
([
i
.
owner
and
i
.
owner
.
op
in
[
host_from_gpu
,
tensor
.
alloc
]
for
i
in
c
.
inputs
[
1
:]])
for
c
,
idx
in
node
.
outputs
[
0
]
.
clients
]):
replace
=
True
if
replace
:
val
=
node
.
inputs
[
0
]
shp
=
node
.
inputs
[
1
:]
old_out
=
node
.
outputs
[
0
]
val2
=
tensor
.
shape_padleft
(
val
,
len
(
shp
)
-
val
.
ndim
)
new_out
=
host_from_gpu
(
gpu_alloc
(
val
,
*
shp
))
if
new_out
.
type
!=
out_out
.
type
:
assert
new_out
.
type
.
ndim
==
old_out
.
type
.
ndim
assert
new_out
.
type
.
dtype
==
old_out
.
type
.
dtype
for
b_old
,
b_new
in
zip
(
old_out
.
type
.
broadcastable
,
new_out
.
type
.
broadcastable
):
assert
b_new
or
(
not
b_old
)
new_out
=
tensor
.
patternbroadcast
(
new_out
.
old_out
.
broadcastable
)
return
[
new_out
]
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论