Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
032c8b5d
提交
032c8b5d
authored
3月 17, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[BUG]Readd the destroyhandler as a requirement for some opt.
This fix bugs on the CPU in fast_compile introduced in: commit
4f8f0da5
Date: Thu Feb 27 09:56:12 2014 -0500
上级
1783f4e9
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
25 行增加
和
12 行删除
+25
-12
opt.py
theano/gof/opt.py
+17
-3
opt.py
theano/sandbox/cuda/opt.py
+3
-3
blas.py
theano/tensor/blas.py
+3
-4
opt.py
theano/tensor/opt.py
+2
-2
没有找到文件。
theano/gof/opt.py
浏览文件 @
032c8b5d
...
...
@@ -790,9 +790,14 @@ class LocalOptimizer(object):
class
FromFunctionLocalOptimizer
(
LocalOptimizer
):
"""WRITEME"""
def
__init__
(
self
,
fn
,
tracks
=
None
):
def
__init__
(
self
,
fn
,
tracks
=
None
,
requirements
=
()
):
self
.
transform
=
fn
self
.
_tracks
=
tracks
self
.
requirements
=
requirements
def
add_requirements
(
self
,
fgraph
):
for
req
in
self
.
requirements
:
req
(
fgraph
)
def
tracks
(
self
):
return
self
.
_tracks
...
...
@@ -808,7 +813,7 @@ class FromFunctionLocalOptimizer(LocalOptimizer):
id
(
self
))
def
local_optimizer
(
tracks
):
def
local_optimizer
(
tracks
,
inplace
=
False
):
def
decorator
(
f
):
"""WRITEME"""
if
tracks
is
not
None
:
...
...
@@ -817,7 +822,12 @@ def local_optimizer(tracks):
for
t
in
tracks
:
if
not
(
isinstance
(
t
,
op
.
Op
)
or
issubclass
(
t
,
op
.
PureOp
)):
raise
ValueError
,
(
"Tracks are op classes or instances"
,
f
.
__module__
,
f
.
__name__
)
rval
=
FromFunctionLocalOptimizer
(
f
,
tracks
)
requirements
=
()
if
inplace
:
dh_handler
=
dh
.
DestroyHandler
requirements
=
(
lambda
fgraph
:
fgraph
.
attach_feature
(
dh_handler
()),)
rval
=
FromFunctionLocalOptimizer
(
f
,
tracks
,
requirements
)
rval
.
__name__
=
f
.
__name__
return
rval
return
decorator
...
...
@@ -852,6 +862,10 @@ class LocalOptGroup(LocalOptimizer):
for
lopt
in
self
.
opts
:
lopt
.
print_summary
(
stream
,
level
=
(
level
+
2
),
depth
=
depth
)
def
add_requirements
(
self
,
fgraph
):
for
opt
in
self
.
opts
:
opt
.
add_requirements
(
fgraph
)
class
_LocalOpKeyOptGroup
(
LocalOptGroup
):
"""WRITEME"""
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
032c8b5d
...
...
@@ -1214,19 +1214,19 @@ def local_gpujoin_1(node):
# shared = dimshuffle(gemm_inplace(dimshuffle(shared)))
# which causes memory leaks (long term fix is to make the above not leak
# memory)
@local_optimizer
([
gpu_gemm_no_inplace
])
@local_optimizer
([
gpu_gemm_no_inplace
]
,
inplace
=
True
)
def
local_inplace_gemm
(
node
):
if
node
.
op
==
gpu_gemm_no_inplace
:
return
[
gpu_gemm_inplace
(
*
node
.
inputs
)]
@local_optimizer
([
gpu_gemv_no_inplace
])
@local_optimizer
([
gpu_gemv_no_inplace
]
,
inplace
=
True
)
def
local_inplace_gemv
(
node
):
if
node
.
op
==
gpu_gemv_no_inplace
:
return
[
gpu_gemv_inplace
(
*
node
.
inputs
)]
@local_optimizer
([
gpu_ger_no_inplace
])
@local_optimizer
([
gpu_ger_no_inplace
]
,
inplace
=
True
)
def
local_inplace_ger
(
node
):
if
node
.
op
==
gpu_ger_no_inplace
:
return
[
gpu_ger_inplace
(
*
node
.
inputs
)]
...
...
theano/tensor/blas.py
浏览文件 @
032c8b5d
...
...
@@ -1715,20 +1715,19 @@ def local_dot_to_dot22(node):
_logger
.
info
(
'Not optimizing dot with inputs
%
s
%
s
%
s
%
s'
,
x
,
y
,
x
.
type
,
y
.
type
)
@local_optimizer
([
gemm_no_inplace
])
@local_optimizer
([
gemm_no_inplace
],
inplace
=
True
)
def
local_inplace_gemm
(
node
):
if
node
.
op
==
gemm_no_inplace
:
return
[
gemm_inplace
(
*
node
.
inputs
)]
@local_optimizer
([
gemv_no_inplace
])
@local_optimizer
([
gemv_no_inplace
]
,
inplace
=
True
)
def
local_inplace_gemv
(
node
):
if
node
.
op
==
gemv_no_inplace
:
return
[
gemv_inplace
(
*
node
.
inputs
)]
@local_optimizer
([
ger
])
@local_optimizer
([
ger
]
,
inplace
=
True
)
def
local_inplace_ger
(
node
):
if
node
.
op
==
ger
:
return
[
ger_destructive
(
*
node
.
inputs
)]
...
...
theano/tensor/opt.py
浏览文件 @
032c8b5d
...
...
@@ -2110,7 +2110,7 @@ compile.optdb.register('pre_local_IncSubtensor_serialize',
#after priority 50 Destructive inplace operations
#gemm is the first one now, at priority 70
@gof.local_optimizer
([
IncSubtensor
]
)
# XXX: GPU
@gof.local_optimizer
([
IncSubtensor
]
,
inplace
=
True
)
def
local_inplace_setsubtensor
(
node
):
"""
Also work for GpuIncSubtensor
...
...
@@ -2129,7 +2129,7 @@ compile.optdb.register('local_inplace_setsubtensor',
'fast_run'
,
'inplace'
)
# DEBUG
@gof.local_optimizer
([
AdvancedIncSubtensor1
]
)
# XXX: GPU
@gof.local_optimizer
([
AdvancedIncSubtensor1
]
,
inplace
=
True
)
def
local_inplace_incsubtensor1
(
node
):
""" also work for GpuAdvancedIncSubtensor1 """
if
isinstance
(
node
.
op
,
AdvancedIncSubtensor1
)
and
not
node
.
op
.
inplace
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论