Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a04ac4bc
提交
a04ac4bc
authored
7月 14, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
8月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename SeqOptimizer to SequentialGraphRewriter
上级
89655604
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
31 行增加
和
28 行删除
+31
-28
opt.py
aesara/graph/opt.py
+10
-5
optdb.py
aesara/graph/optdb.py
+5
-7
graph_rewriting.rst
doc/extending/graph_rewriting.rst
+15
-15
test_optdb.py
tests/graph/test_optdb.py
+1
-1
没有找到文件。
aesara/graph/opt.py
浏览文件 @
a04ac4bc
...
...
@@ -231,13 +231,13 @@ def inplace_graph_rewriter(f):
return
rval
class
Seq
Optimiz
er
(
GraphRewriter
,
UserList
):
class
Seq
uentialGraphRewrit
er
(
GraphRewriter
,
UserList
):
"""A `GraphRewriter` that applies a list of optimizers sequentially."""
@staticmethod
def
warn
(
exc
,
self
,
optimizer
):
"""Default ``failure_callback`` for `Seq
Optimiz
er`."""
_logger
.
error
(
f
"Seq
Optimiz
er apply {optimizer}"
)
"""Default ``failure_callback`` for `Seq
uentialGraphRewrit
er`."""
_logger
.
error
(
f
"Seq
uentialGraphRewrit
er apply {optimizer}"
)
_logger
.
error
(
"Traceback:"
)
_logger
.
error
(
traceback
.
format_exc
())
if
config
.
on_opt_error
==
"raise"
:
...
...
@@ -378,7 +378,7 @@ class SeqOptimizer(GraphRewriter, UserList):
blanc
=
" "
*
level
print
(
blanc
,
"Seq
Optimiz
er"
,
end
=
" "
,
file
=
stream
)
print
(
blanc
,
"Seq
uentialGraphRewrit
er"
,
end
=
" "
,
file
=
stream
)
if
hasattr
(
opts
,
"name"
):
print
(
blanc
,
opts
.
name
,
end
=
" "
,
file
=
stream
)
elif
hasattr
(
opts
,
"__name__"
):
...
...
@@ -487,7 +487,7 @@ class SeqOptimizer(GraphRewriter, UserList):
new_l
.
append
(
l
)
new_sub_profile
.
append
(
p
[
6
][
idx
])
new_opt
=
Seq
Optimiz
er
(
*
new_l
)
new_opt
=
Seq
uentialGraphRewrit
er
(
*
new_l
)
new_nb_nodes
=
[]
for
p1
,
p2
in
zip
(
prof1
[
8
],
prof2
[
8
]):
new_nb_nodes
.
append
((
p1
[
0
]
+
p2
[
0
],
p1
[
1
]
+
p2
[
1
]))
...
...
@@ -3153,6 +3153,11 @@ DEPRECATED_NAMES = [
"`LocalMetaOptimizer` is deprecated: use `MetaNodeRewriter` instead."
,
MetaNodeRewriter
,
),
(
"SeqOptimizer"
,
"`SeqOptimizer` is deprecated: use `SequentialGraphRewriter` instead."
,
SequentialGraphRewriter
,
),
]
...
...
aesara/graph/optdb.py
浏览文件 @
a04ac4bc
...
...
@@ -353,22 +353,20 @@ class EquilibriumDB(OptimizationDatabase):
class
SequenceDB
(
OptimizationDatabase
):
"""A sequence of potential
optimization
s.
"""A sequence of potential
rewrite
s.
Retrieve a sequence of optimizations (a SeqOptimizer) by calling query().
Retrieve a sequence of rewrites as a `SequentialGraphRewriter` by calling
`SequenceDB.query`.
Each potential optimization is registered with a floating-point position.
No matter which optimizations are selected by a query, they are carried
out in order of increasing position.
The optdb itself (`aesara.compile.mode.optdb`), from which (among many
other tags) fast_run and fast_compile optimizers are drawn is a SequenceDB.
"""
seq_opt
=
aesara_opt
.
Seq
Optimiz
er
seq_opt
=
aesara_opt
.
Seq
uentialGraphRewrit
er
def
__init__
(
self
,
failure_callback
=
aesara_opt
.
Seq
Optimiz
er
.
warn
):
def
__init__
(
self
,
failure_callback
=
aesara_opt
.
Seq
uentialGraphRewrit
er
.
warn
):
super
()
.
__init__
()
self
.
__position__
=
{}
self
.
failure_callback
=
failure_callback
...
...
doc/extending/graph_rewriting.rst
浏览文件 @
a04ac4bc
...
...
@@ -747,7 +747,7 @@ two or more states and nothing will get done.
:obj:`optdb` structure
----------------------
:obj:`optdb` contains the following :class:`
Optimizer
`\s and sub-DBs, with the given
:obj:`optdb` contains the following :class:`
Rewriters
`\s and sub-DBs, with the given
priorities and tags:
+-------+---------------------+------------------------------+
...
...
@@ -855,7 +855,7 @@ This will output something like this:
Optimizer Profile
-----------------
Seq
Optimiz
er OPT_FAST_RUN time 1.152s for 123/50 nodes before/after optimization
Seq
uentialGraphRewrit
er OPT_FAST_RUN time 1.152s for 123/50 nodes before/after optimization
0.028s for fgraph.validate()
0.131s for callback
time - (name, class, index) - validate time
...
...
@@ -924,8 +924,8 @@ This will output something like this:
0.000s - local_subtensor_of_alloc
0.000s - local_subtensor_of_dot
0.000s - local_subtensor_merge
0.101733s - ('elemwise_fusion', 'Seq
Optimiz
er', 13) - 0.000s
Seq
Optimiz
er elemwise_fusion time 0.102s for 78/50 nodes before/after optimization
0.101733s - ('elemwise_fusion', 'Seq
uentialGraphRewrit
er', 13) - 0.000s
Seq
uentialGraphRewrit
er elemwise_fusion time 0.102s for 78/50 nodes before/after optimization
0.000s for fgraph.validate()
0.004s for callback
0.095307s - ('composite_elemwise_fusion', 'FusionOptimizer', 1) - 0.000s
...
...
@@ -945,8 +945,8 @@ This will output something like this:
callback_time 0.000783205032349
time_toposort 0.0035240650177
0.090089s - ('inplace_elemwise_optimizer', 'FromFunctionGraphRewriter', 30) - 0.019s
0.048993s - ('BlasOpt', 'Seq
Optimiz
er', 8) - 0.000s
Seq
Optimiz
er BlasOpt time 0.049s for 81/80 nodes before/after optimization
0.048993s - ('BlasOpt', 'Seq
uentialGraphRewrit
er', 8) - 0.000s
Seq
uentialGraphRewrit
er BlasOpt time 0.049s for 81/80 nodes before/after optimization
0.000s for fgraph.validate()
0.003s for callback
0.035997s - ('gemm_optimizer', 'GemmOptimizer', 1) - 0.000s
...
...
@@ -1042,21 +1042,21 @@ This will output something like this:
To understand this profile here is some explanation of how optimizations work:
* Optimizations are organized in an hierarchy. At the top level, there
is a :class:`Seq
Optimiz
er`. It contains other optimizers,
is a :class:`Seq
uentialGraphRewrit
er`. It contains other optimizers,
and applies them in the order they were specified. Those sub-optimizers can be
of other types, but are all *global* optimizers.
* Each :class:`
Optimiz
er` in the hierarchy will print some stats about
* Each :class:`
Rewrit
er` in the hierarchy will print some stats about
itself. The information that it prints depends of the type of the
optimizer.
* The :class:`Seq
Optimiz
er` will print some stats at the start:
* The :class:`Seq
uentialGraphRewrit
er` will print some stats at the start:
.. code-block:: none
Optimizer Profile
-----------------
Seq
Optimiz
er OPT_FAST_RUN time 1.152s for 123/50 nodes before/after optimization
Seq
uentialGraphRewrit
er OPT_FAST_RUN time 1.152s for 123/50 nodes before/after optimization
0.028s for fgraph.validate()
0.131s for callback
time - (name, class, index) - validate time
...
...
@@ -1071,12 +1071,12 @@ To understand this profile here is some explanation of how optimizations work:
* 0.028s means it spent that time calls to ``fgraph.validate()``
* 0.131s means it spent that time for callbacks. This is a mechanism that can trigger other execution when there is a change to the FunctionGraph.
* ``time - (name, class, index) - validate time`` tells how the information for each sub-optimizer get printed.
* All other instances of :class:`Seq
Optimiz
er` are described like this. In
* All other instances of :class:`Seq
uentialGraphRewrit
er` are described like this. In
particular, some sub-optimizer from ``OPT_FAST_RUN`` that are also
:class:`Seq
Optimiz
er`.
:class:`Seq
uentialGraphRewrit
er`.
* The :class:`Seq
Optimiz
er` will print some stats at the start:
* The :class:`Seq
uentialGraphRewrit
er` will print some stats at the start:
.. code-block:: none
...
...
@@ -1147,11 +1147,11 @@ To understand this profile here is some explanation of how optimizations work:
0.000s - local_subtensor_merge
* ``0.751816s - ('canonicalize', 'EquilibriumOptimizer', 4) - 0.004s``
This line is from :class:`Seq
Optimiz
er`, and indicates information related
This line is from :class:`Seq
uentialGraphRewrit
er`, and indicates information related
to a sub-optimizer. It means that this sub-optimizer took
a total of .7s. Its name is ``'canonicalize'``. It is an
:class:`EquilibriumOptimizer`. It was executed at index 4 by the
:class:`Seq
Optimiz
er`. It spent 0.004s in the *validate* phase.
:class:`Seq
uentialGraphRewrit
er`. It spent 0.004s in the *validate* phase.
* All other lines are from the profiler of the :class:`EquilibriumOptimizer`.
* An :class:`EquilibriumOptimizer` does multiple passes on the Apply nodes from
...
...
tests/graph/test_optdb.py
浏览文件 @
a04ac4bc
...
...
@@ -53,7 +53,7 @@ class TestDB:
res
=
seq_db
.
query
(
"+a"
)
assert
isinstance
(
res
,
opt
.
Seq
Optimiz
er
)
assert
isinstance
(
res
,
opt
.
Seq
uentialGraphRewrit
er
)
assert
res
.
data
==
[]
seq_db
.
register
(
"b"
,
TestOpt
(),
position
=
1
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论