Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
bfa1f2d4
提交
bfa1f2d4
authored
9月 21, 2015
作者:
carriepl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Various fixes in optdb.py
上级
49230a8d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
12 行删除
+18
-12
optdb.py
theano/gof/optdb.py
+18
-12
没有找到文件。
theano/gof/optdb.py
浏览文件 @
bfa1f2d4
...
...
@@ -178,12 +178,15 @@ class Query(object):
"""
def
__init__
(
self
,
include
,
require
=
None
,
exclude
=
None
,
subquery
=
None
,
position_cutoff
=
None
,
extra_optimizations
=
[]):
subquery
=
None
,
position_cutoff
=
None
,
extra_optimizations
=
None
):
self
.
include
=
OrderedSet
(
include
)
self
.
require
=
require
or
OrderedSet
()
self
.
exclude
=
exclude
or
OrderedSet
()
self
.
subquery
=
subquery
or
{}
self
.
position_cutoff
=
position_cutoff
if
extra_optimizations
is
None
:
extra_optimizations
=
[]
self
.
extra_optimizations
=
extra_optimizations
if
isinstance
(
self
.
require
,
(
list
,
tuple
)):
self
.
require
=
OrderedSet
(
self
.
require
)
...
...
@@ -337,23 +340,26 @@ class SequenceDB(DB):
# The Query instance might contain extra optimizations which need
# to be added the the sequence of optimizations (don't alter the
# original dictionary)
position_dict
=
position_dict
.
copy
()
for
extra_opt
in
tags
[
0
]
.
extra_optimizations
:
# Give a name to the extra optimization
opt
,
position
=
extra_opt
opt
.
name
=
str
(
opt
.
__class__
)
# Add the extra optimization to the optimization sequence
opts
.
add
(
opt
)
position_dict
[
opt
.
name
]
=
position
if
len
(
tags
[
0
]
.
extra_optimizations
)
>
0
:
position_dict
=
position_dict
.
copy
()
for
extra_opt
in
tags
[
0
]
.
extra_optimizations
:
# Give a name to the extra optimization (include both the
# class name for descriptiveness and id to avoid name
# collisions)
opt
,
position
=
extra_opt
opt
.
name
=
"
%
s_
%
i"
%
(
opt
.
__class__
,
id
(
opt
))
# Add the extra optimization to the optimization sequence
if
position
<
position_cutoff
:
opts
.
add
(
opt
)
position_dict
[
opt
.
name
]
=
position
opts
=
[
o
for
o
in
opts
if
position_dict
[
o
.
name
]
<
position_cutoff
]
# We want to sort by position and then if collision by name
# for deterministic optimization. Since Python 2.2, sort is
# stable, so sort by name first, then by position. This give
# the order we want.
opts
.
sort
(
key
=
lambda
obj
:
obj
.
name
)
opts
.
sort
(
key
=
lambda
obj
:
position_dict
[
obj
.
name
])
opts
.
sort
(
key
=
lambda
obj
:
(
position_dict
[
obj
.
name
],
obj
.
name
))
kwargs
=
{}
if
self
.
failure_callback
:
kwargs
[
"failure_callback"
]
=
self
.
failure_callback
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论