Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2f986160
提交
2f986160
authored
9月 23, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add proper context inference for scan.
上级
c032ac66
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
8 行删除
+27
-8
opt.py
theano/sandbox/cuda/opt.py
+4
-1
opt.py
theano/sandbox/gpuarray/opt.py
+14
-3
scan_opt.py
theano/scan_module/scan_opt.py
+9
-4
没有找到文件。
theano/sandbox/cuda/opt.py
浏览文件 @
2f986160
...
@@ -2478,8 +2478,11 @@ def local_gpu_allocempty(node):
...
@@ -2478,8 +2478,11 @@ def local_gpu_allocempty(node):
return
False
return
False
def
typeInfer
(
node
):
return
typeConstructor
optdb
.
register
(
'gpu_scanOp_make_inplace'
,
optdb
.
register
(
'gpu_scanOp_make_inplace'
,
scan_opt
.
ScanInplaceOptimizer
(
type
Constructor
=
typeConstructo
r
,
scan_opt
.
ScanInplaceOptimizer
(
type
Infer
=
typeInfe
r
,
gpu_flag
=
True
),
gpu_flag
=
True
),
75
,
75
,
'gpu'
,
'gpu'
,
...
...
theano/sandbox/gpuarray/opt.py
浏览文件 @
2f986160
...
@@ -18,7 +18,7 @@ from theano.tensor.nnet.conv import ConvOp
...
@@ -18,7 +18,7 @@ from theano.tensor.nnet.conv import ConvOp
from
theano.tests.breakpoint
import
PdbBreakpoint
from
theano.tests.breakpoint
import
PdbBreakpoint
from
.type
import
GpuArrayType
,
GpuArrayConstant
,
get_context
from
.type
import
GpuArrayType
,
GpuArrayConstant
,
get_context
from
.basic_ops
import
(
as_gpuarray_variable
,
from
.basic_ops
import
(
as_gpuarray_variable
,
infer_context_name
,
host_from_gpu
,
GpuToGpu
,
host_from_gpu
,
GpuToGpu
,
HostFromGpu
,
GpuFromHost
,
HostFromGpu
,
GpuFromHost
,
GpuSplit
,
GpuContiguous
,
GpuSplit
,
GpuContiguous
,
...
@@ -961,12 +961,23 @@ def local_scan_to_gpua(node, context_name):
...
@@ -961,12 +961,23 @@ def local_scan_to_gpua(node, context_name):
_cmodule_key
=
gof
.
CLinker
()
.
cmodule_key_
(
local_fgraph
,
[])
_cmodule_key
=
gof
.
CLinker
()
.
cmodule_key_
(
local_fgraph
,
[])
info
[
'gpu_hash'
]
=
hash
(
_cmodule_key
)
info
[
'gpu_hash'
]
=
hash
(
_cmodule_key
)
def
typebuild
(
dtype
,
broadcastable
,
context_name
=
context_name
):
return
GpuArrayType
(
dtype
=
dtype
,
broadcastable
=
broadcastable
,
context_name
=
context_name
)
nw_op
=
scan_op
.
Scan
(
scan_ins
,
scan_outs
,
info
,
nw_op
=
scan_op
.
Scan
(
scan_ins
,
scan_outs
,
info
,
type
Constructor
=
GpuArrayType
)
.
make_node
(
*
nw_ins
)
type
build
=
typebuild
)
.
make_node
(
*
nw_ins
)
return
nw_op
.
outputs
return
nw_op
.
outputs
def
_scan_type_infer
(
node
):
context_name
=
infer_context_name
(
*
node
.
inputs
)
def
typebuild
(
dtype
,
broadcastable
,
context_name
=
context_name
):
return
GpuArrayType
(
dtype
=
dtype
,
broadcastable
=
broadcastable
,
context_name
=
context_name
)
return
typebuild
optdb
.
register
(
'gpua_scanOp_make_inplace'
,
optdb
.
register
(
'gpua_scanOp_make_inplace'
,
scan_opt
.
ScanInplaceOptimizer
(
type
Constructor
=
GpuArrayType
,
scan_opt
.
ScanInplaceOptimizer
(
type
Infer
=
_scan_type_infer
,
gpua_flag
=
True
),
gpua_flag
=
True
),
75
,
75
,
'gpuarray'
,
'gpuarray'
,
...
...
theano/scan_module/scan_opt.py
浏览文件 @
2f986160
...
@@ -1014,9 +1014,9 @@ class ScanInplaceOptimizer(Optimizer):
...
@@ -1014,9 +1014,9 @@ class ScanInplaceOptimizer(Optimizer):
"""
"""
def
__init__
(
self
,
type
Constructo
r
=
None
,
gpu_flag
=
False
,
gpua_flag
=
False
):
def
__init__
(
self
,
type
Infe
r
=
None
,
gpu_flag
=
False
,
gpua_flag
=
False
):
Optimizer
.
__init__
(
self
)
Optimizer
.
__init__
(
self
)
self
.
type
Constructor
=
typeConstructo
r
self
.
type
Infer
=
typeInfe
r
self
.
gpu_flag
=
gpu_flag
self
.
gpu_flag
=
gpu_flag
self
.
gpua_flag
=
gpua_flag
self
.
gpua_flag
=
gpua_flag
...
@@ -1062,10 +1062,15 @@ class ScanInplaceOptimizer(Optimizer):
...
@@ -1062,10 +1062,15 @@ class ScanInplaceOptimizer(Optimizer):
ls
[
idx
]
=
deep_copy_op
(
ls
[
idx
])
ls
[
idx
]
=
deep_copy_op
(
ls
[
idx
])
inputs
=
ls_begin
+
ls
+
ls_end
inputs
=
ls_begin
+
ls
+
ls_end
if
self
.
typeInfer
is
None
:
typeConstructor
=
None
else
:
typeConstructor
=
self
.
typeInfer
(
node
)
new_op
=
scan_op
.
Scan
(
op
.
inputs
,
new_op
=
scan_op
.
Scan
(
op
.
inputs
,
op
.
outputs
,
op
.
outputs
,
info
,
info
,
typeConstructor
=
self
.
typeConstructor
)
typeConstructor
=
typeConstructor
)
# Do not call make_node for test_value
# Do not call make_node for test_value
new_outs
=
new_op
(
*
inputs
,
**
dict
(
return_list
=
True
))
new_outs
=
new_op
(
*
inputs
,
**
dict
(
return_list
=
True
))
...
@@ -2298,7 +2303,7 @@ scan_eqopt2 = theano.gof.EquilibriumDB()
...
@@ -2298,7 +2303,7 @@ scan_eqopt2 = theano.gof.EquilibriumDB()
optdb
.
register
(
'scan_eqopt1'
,
scan_eqopt1
,
.
1
,
'fast_run'
,
'scan'
)
optdb
.
register
(
'scan_eqopt1'
,
scan_eqopt1
,
.
1
,
'fast_run'
,
'scan'
)
optdb
.
register
(
'scan_eqopt2'
,
scan_eqopt2
,
1.6
,
'fast_run'
,
'scan'
)
optdb
.
register
(
'scan_eqopt2'
,
scan_eqopt2
,
1.6
,
'fast_run'
,
'scan'
)
optdb
.
register
(
'scanOp_make_inplace'
,
optdb
.
register
(
'scanOp_make_inplace'
,
ScanInplaceOptimizer
(
type
Constructo
r
=
None
,
ScanInplaceOptimizer
(
type
Infe
r
=
None
,
gpu_flag
=
False
),
gpu_flag
=
False
),
75
,
75
,
'fast_run'
,
'fast_run'
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论