Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
371c5447
提交
371c5447
authored
7月 15, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
8月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename OpRemove to RemovalNodeRewriter
上级
2d0057d4
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
15 行增加
和
10 行删除
+15
-10
opt.py
aesara/graph/opt.py
+6
-1
basic_opt.py
aesara/tensor/basic_opt.py
+2
-2
graph_rewriting.rst
doc/extending/graph_rewriting.rst
+7
-7
没有找到文件。
aesara/graph/opt.py
浏览文件 @
371c5447
...
...
@@ -1446,7 +1446,7 @@ class SubstitutionNodeRewriter(NodeRewriter):
return
f
"{self.op1} -> {self.op2}"
class
OpRemove
(
NodeRewriter
):
class
RemovalNodeRewriter
(
NodeRewriter
):
"""
Removes all applications of an `Op` by transferring each of its
outputs to the corresponding input.
...
...
@@ -3178,6 +3178,11 @@ DEPRECATED_NAMES = [
"`OpSub` is deprecated: use `SubstitutionNodeRewriter` instead."
,
SubstitutionNodeRewriter
,
),
(
"OpRemove"
,
"`OpRemove` is deprecated: use `RemovalNodeRewriter` instead."
,
RemovalNodeRewriter
,
),
]
...
...
aesara/tensor/basic_opt.py
浏览文件 @
371c5447
...
...
@@ -29,7 +29,7 @@ from aesara.graph.op import compute_test_value, get_test_value
from
aesara.graph.opt
import
(
GraphRewriter
,
NodeRewriter
,
OpRemove
,
RemovalNodeRewriter
,
Rewriter
,
check_chain
,
copy_stack_trace
,
...
...
@@ -2744,7 +2744,7 @@ def local_reshape_lift(fgraph, node):
return
[
e
]
register_canonicalize
(
OpRemove
(
tensor_copy
),
name
=
"remove_tensor_copy"
)
register_canonicalize
(
RemovalNodeRewriter
(
tensor_copy
),
name
=
"remove_tensor_copy"
)
@node_rewriter
(
None
)
...
...
doc/extending/graph_rewriting.rst
浏览文件 @
371c5447
...
...
@@ -270,8 +270,8 @@ FunctionGraph(add(z, mul(true_div(mul(y, x), y), true_div(z, x))))
>>> e
FunctionGraph(add(z, mul(x, true_div(z, x))))
:class:`SubstitutionNodeRewriter`, :class:`
OpRemove
`, :class:`PatternSub`
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:class:`SubstitutionNodeRewriter`, :class:`
RemovalNodeRewriter
`, :class:`PatternSub`
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++
Aesara defines some shortcuts to make :class:`NodeRewriter`\s:
...
...
@@ -281,7 +281,7 @@ Aesara defines some shortcuts to make :class:`NodeRewriter`\s:
words, the outputs of all :class:`Apply` nodes using ``op1`` by the outputs
of :class:`Apply` nodes involving ``op2``, where their inputs are the same.
.. function::
OpRemove
(op)
.. function::
RemovalNodeRewriter
(op)
Removes all uses of ``op`` in the following way:
if ``y = op(x)`` then ``y`` is replaced by ``x``. ``op`` must have as many
...
...
@@ -296,14 +296,14 @@ Aesara defines some shortcuts to make :class:`NodeRewriter`\s:
.. code::
from aesara.scalar import identity
from aesara.graph.opt import SubstitutionNodeRewriter,
OpRemove
, PatternSub
from aesara.graph.opt import SubstitutionNodeRewriter,
RemovalNodeRewriter
, PatternSub
# Replacing `add` by `mul` (this is not recommended for primarily
# mathematical reasons):
add_to_mul = SubstitutionNodeRewriter(add, mul)
# Removing `identity`
remove_identity =
OpRemove
(identity)
remove_identity =
RemovalNodeRewriter
(identity)
# The "simplify" operation we've been defining in the past few
# sections. Note that we need two patterns to account for the
...
...
@@ -313,12 +313,12 @@ Aesara defines some shortcuts to make :class:`NodeRewriter`\s:
.. note::
:class:`SubstitutionNodeRewriter`, :class:`
OpRemove
` and :class:`PatternSub` produce local optimizers, which
:class:`SubstitutionNodeRewriter`, :class:`
RemovalNodeRewriter
` and :class:`PatternSub` produce local optimizers, which
means that everything we said previously about local optimizers
apply (e.g. they need to be wrapped in a :class:`NavigatorOptimizer`, etc.)
When an optimization can be naturally expressed using :class:`SubstitutionNodeRewriter`, :class:`
OpRemove
`
When an optimization can be naturally expressed using :class:`SubstitutionNodeRewriter`, :class:`
RemovalNodeRewriter
`
or :class:`PatternSub`, it is highly recommended to use them.
.. _unification:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论