Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
246ed4db
提交
246ed4db
authored
5月 10, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debug: cuda.opt local_cut_gpu_host_gpu
上级
eb0860ea
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
4 行删除
+23
-4
opt.py
theano/sandbox/cuda/opt.py
+9
-3
opt.py
theano/tensor/opt.py
+14
-1
没有找到文件。
theano/sandbox/cuda/opt.py
浏览文件 @
246ed4db
...
@@ -2,7 +2,7 @@ import sys
...
@@ -2,7 +2,7 @@ import sys
import
theano
import
theano
import
numpy
import
numpy
from
theano
import
scalar
as
scal
from
theano
import
scalar
as
scal
from
theano
import
tensor
,
compile
from
theano
import
tensor
,
compile
,
gof
from
theano.gof
import
local_optimizer
,
EquilibriumDB
,
SequenceDB
,
Optimizer
,
toolbox
,
DestroyHandler
from
theano.gof
import
local_optimizer
,
EquilibriumDB
,
SequenceDB
,
Optimizer
,
toolbox
,
DestroyHandler
from
theano.sandbox.cuda.basic_ops
import
*
from
theano.sandbox.cuda.basic_ops
import
*
...
@@ -62,10 +62,16 @@ gpu_seqopt.register('InputToGpuOptimizer', InputToGpuOptimizer(),
...
@@ -62,10 +62,16 @@ gpu_seqopt.register('InputToGpuOptimizer', InputToGpuOptimizer(),
@local_optimizer
([])
@local_optimizer
([])
def
local_cut_gpu_host_gpu
(
node
):
def
local_cut_gpu_host_gpu
(
node
):
copy_op
=
None
if
tensor
.
opt
.
opt
.
check_chain
(
node
,
gpu_from_host
,
host_from_gpu
):
if
tensor
.
opt
.
opt
.
check_chain
(
node
,
gpu_from_host
,
host_from_gpu
):
return
[
node
.
inputs
[
0
]
.
owner
.
inputs
[
0
]]
copy_op
=
GpuElemwise
(
scal
.
identity
,
{})
if
tensor
.
opt
.
opt
.
check_chain
(
node
,
host_from_gpu
,
gpu_from_host
):
if
tensor
.
opt
.
opt
.
check_chain
(
node
,
host_from_gpu
,
gpu_from_host
):
return
[
node
.
inputs
[
0
]
.
owner
.
inputs
[
0
]]
copy_op
=
tensor
.
copy
if
copy_op
:
#copy_op = lambda x:x
rval
=
copy_op
(
node
.
inputs
[
0
]
.
owner
.
inputs
[
0
])
assert
isinstance
(
rval
,
gof
.
Variable
),
"rval is not a variable"
return
[
rval
]
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'
)
...
...
theano/tensor/opt.py
浏览文件 @
246ed4db
...
@@ -1063,11 +1063,18 @@ def local_fill_cut(node):
...
@@ -1063,11 +1063,18 @@ def local_fill_cut(node):
If c.type == a.type.
If c.type == a.type.
"""
"""
# this optimization is essentially for getting broadcasting to replace fill.
# This is always possible when using a Compound Elemwise operation,
# but it is not always possible without one (consider filling a large matrix with a scalar,
# and then adding another scalar. The only numbers that count are the two scalars, but we
# can't ignore the large matrix because it gives the shape of the result.
if
not
opt
.
check_chain
(
node
,
T
.
Elemwise
):
if
not
opt
.
check_chain
(
node
,
T
.
Elemwise
):
return
False
return
False
output
=
node
.
outputs
[
0
]
output
=
node
.
outputs
[
0
]
try
:
try
:
#reference is some input with the same type as the input but that is not produced by a fill
reference
=
[
input
reference
=
[
input
for
input
in
node
.
inputs
for
input
in
node
.
inputs
if
input
.
type
==
output
.
type
and
(
not
input
.
owner
or
input
.
owner
.
op
!=
T
.
fill
)][
0
]
if
input
.
type
==
output
.
type
and
(
not
input
.
owner
or
input
.
owner
.
op
!=
T
.
fill
)][
0
]
...
@@ -1086,7 +1093,13 @@ def local_fill_cut(node):
...
@@ -1086,7 +1093,13 @@ def local_fill_cut(node):
if
new_inputs
==
node
.
inputs
:
if
new_inputs
==
node
.
inputs
:
return
False
return
False
return
node
.
op
.
make_node
(
*
new_inputs
)
.
outputs
print
'NEW INPUTS'
,
new_inputs
rval
=
node
.
op
(
*
new_inputs
)
if
isinstance
(
rval
,
gof
.
Variable
):
return
rval
.
owner
.
outputs
else
:
return
rval
[
0
]
.
owner
.
outputs
register_canonicalize
(
local_fill_cut
)
register_canonicalize
(
local_fill_cut
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论