Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e2fa5912
提交
e2fa5912
authored
9月 28, 2016
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Get some inplace stats
上级
5cbbcb72
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
12 行增加
和
0 行删除
+12
-0
opt.py
theano/tensor/opt.py
+12
-0
没有找到文件。
theano/tensor/opt.py
浏览文件 @
e2fa5912
...
@@ -5,6 +5,7 @@ Tensor optimizations addressing the ops in basic.py.
...
@@ -5,6 +5,7 @@ Tensor optimizations addressing the ops in basic.py.
# TODO: intelligent merge for mul/add
# TODO: intelligent merge for mul/add
# TODO: 0*x -> 0
# TODO: 0*x -> 0
from
collections
import
defaultdict
import
logging
import
logging
import
itertools
import
itertools
import
operator
import
operator
...
@@ -187,6 +188,12 @@ def inplace_elemwise_optimizer_op(OP):
...
@@ -187,6 +188,12 @@ def inplace_elemwise_optimizer_op(OP):
# the solution is also applicable there.
# the solution is also applicable there.
# We execute `validate` after this number of change.
# We execute `validate` after this number of change.
prof
=
{
'node_before'
:
len
(
fgraph
.
apply_nodes
),
'nb_call_replace'
:
0
,
'nb_call_validate'
:
0
,
'nb_inconsistent'
:
0
,
'ndim'
:
defaultdict
(
lambda
:
0
)}
check_each_change
=
config
.
tensor
.
insert_inplace_optimizer_validate_nb
check_each_change
=
config
.
tensor
.
insert_inplace_optimizer_validate_nb
if
check_each_change
==
-
1
:
if
check_each_change
==
-
1
:
if
len
(
fgraph
.
apply_nodes
)
>
500
:
if
len
(
fgraph
.
apply_nodes
)
>
500
:
...
@@ -332,14 +339,18 @@ def inplace_elemwise_optimizer_op(OP):
...
@@ -332,14 +339,18 @@ def inplace_elemwise_optimizer_op(OP):
new_node
=
new_outputs
[
0
]
.
owner
new_node
=
new_outputs
[
0
]
.
owner
for
r
,
new_r
in
zip
(
node
.
outputs
,
new_outputs
):
for
r
,
new_r
in
zip
(
node
.
outputs
,
new_outputs
):
prof
[
'nb_call_replace'
]
+=
1
fgraph
.
replace
(
r
,
new_r
,
fgraph
.
replace
(
r
,
new_r
,
reason
=
"inplace_elemwise_optimizer"
)
reason
=
"inplace_elemwise_optimizer"
)
nb_change_no_validate
+=
1
nb_change_no_validate
+=
1
prof
[
'ndim'
][
node
.
ndim
]
+=
1
if
nb_change_no_validate
>=
check_each_change
:
if
nb_change_no_validate
>=
check_each_change
:
prof
[
'nb_call_validate'
]
+=
1
fgraph
.
validate
()
fgraph
.
validate
()
chk
=
fgraph
.
checkpoint
()
chk
=
fgraph
.
checkpoint
()
nb_change_no_validate
=
0
nb_change_no_validate
=
0
except
(
ValueError
,
InconsistencyError
)
as
e
:
except
(
ValueError
,
InconsistencyError
)
as
e
:
prof
[
'nb_inconsistent'
]
+=
1
if
check_each_change
!=
1
and
not
raised_warning
:
if
check_each_change
!=
1
and
not
raised_warning
:
print
((
"Some inplace optimization was not "
print
((
"Some inplace optimization was not "
"performed due to unexpected error:"
),
"performed due to unexpected error:"
),
...
@@ -362,6 +373,7 @@ def inplace_elemwise_optimizer_op(OP):
...
@@ -362,6 +373,7 @@ def inplace_elemwise_optimizer_op(OP):
"performed due to unexpected error"
),
"performed due to unexpected error"
),
file
=
sys
.
stderr
)
file
=
sys
.
stderr
)
fgraph
.
revert
(
chk
)
fgraph
.
revert
(
chk
)
print
(
prof
)
return
inplace_elemwise_optimizer
return
inplace_elemwise_optimizer
inplace_elemwise_optimizer
=
inplace_elemwise_optimizer_op
(
T
.
Elemwise
)
inplace_elemwise_optimizer
=
inplace_elemwise_optimizer_op
(
T
.
Elemwise
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论