Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c12e1612
提交
c12e1612
authored
9月 13, 2013
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add optimisations for GpuDimShuffle and SpecifyShape.
上级
a1bbaede
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
60 行增加
和
2 行删除
+60
-2
opt.py
theano/sandbox/gpuarray/opt.py
+60
-2
没有找到文件。
theano/sandbox/gpuarray/opt.py
浏览文件 @
c12e1612
...
...
@@ -9,8 +9,11 @@ from theano.gof import (local_optimizer, EquilibriumDB, SequenceDB, ProxyDB,
from
theano.gof.python25
import
all
,
any
from
theano.sandbox.gpuarray.type
import
GpuArrayType
from
basic_ops
import
host_from_gpu
,
gpu_from_host
,
gpu_alloc
from
elemwise
import
GpuElemwise
,
_is_scalar
from
theano.sandbox.gpuarray.basic_ops
import
(
host_from_gpu
,
gpu_from_host
,
gpu_alloc
)
from
theano.sandbox.gpuarray.elemwise
import
(
GpuElemwise
,
_is_scalar
,
GpuDimShuffle
)
from
theano.sandbox.gpuarray.subtensor
import
GpuSubtensor
gpu_optimizer
=
EquilibriumDB
()
gpu_cut_copies
=
EquilibriumDB
()
...
...
@@ -36,6 +39,24 @@ def register_opt(*tags, **kwargs):
register_opt
()(
theano
.
tensor
.
opt
.
local_track_shape_i
)
def
op_lifter
(
OP
):
def
f
(
maker
):
def
local_opt
(
node
):
if
isinstance
(
node
.
op
,
OP
):
input
,
=
node
.
inputs
if
input
.
owner
and
input
.
owner
.
op
==
host_from_gpu
:
new_op
=
maker
(
node
)
return
[
host_from_gpu
(
new_op
(
input
))]
if
node
.
op
==
gpu_from_host
:
host_input
=
node
.
inputs
[
0
]
if
host_input
.
owner
and
isinstance
(
host_input
.
owner
.
op
,
OP
):
new_op
=
maker
(
host_input
.
owner
)
return
[
new_op
(
gpu_from_host
(
host_input
.
owner
.
inputs
[
0
]))]
return
False
local_opt
.
__name__
=
maker
.
__name__
return
local_opt
return
f
class
InputToGpuOptimizer
(
Optimizer
):
"Transfer the input to the gpu to start the rolling wave."
...
...
@@ -175,3 +196,40 @@ inplace_gpu_elemwise_opt = tensor.opt.inplace_elemwise_optimizer_op(
GpuElemwise
)
optdb
.
register
(
'gpua_inplace_opt'
,
inplace_gpu_elemwise_opt
,
75
,
'inplace_elemwise_optimizer'
,
'fast_run'
,
'inplace'
)
@register_opt
()
@local_optimizer
([])
@op_lifter
(
tensor
.
DimShuffle
)
def
local_gpua_dimshuffle
(
node
):
return
GpuDimShuffle
(
node
.
op
.
input_broadcastable
,
node
.
op
.
new_order
)
@register_opt
()
@local_optimizer
([])
@op_lifter
(
tensor
.
SpecifyShape
)
def
local_gpua_specifyShape
(
node
):
return
tensor
.
specify_shape
(
gpu_from_host
(
node
.
inputs
[
0
]),
*
node
.
inputs
[
1
:])
@register_opt
()
@local_optimizer
([])
def
local_gpua_subtensor
(
node
):
if
node
.
op
==
gpu_from_host
:
host_input
=
node
.
inputs
[
0
]
if
host_input
.
owner
and
\
isinstance
(
host_input
.
owner
.
op
,
tensor
.
Subtensor
):
subt
=
host_input
.
owner
.
op
x
=
host_input
.
owner
.
inputs
[
0
]
coords
=
host_input
.
owner
.
inputs
[
1
:]
return
[
GpuSubtensor
(
subt
.
idx_list
)(
gpu_from_host
(
x
),
*
coords
)]
if
isinstance
(
node
.
op
,
tensor
.
Subtensor
):
x
=
node
.
inputs
[
0
]
coords
=
node
.
inputs
[
1
:]
if
x
.
owner
and
x
.
owner
.
op
==
host_from_gpu
:
gpu_x
,
=
x
.
owner
.
inputs
return
[
host_from_gpu
(
GpuSubtensor
(
node
.
op
.
idx_list
)(
gpu_x
,
*
coords
))]
return
False
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论