提交 371c5447 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Rename OpRemove to RemovalNodeRewriter

上级 2d0057d4
...@@ -1446,7 +1446,7 @@ class SubstitutionNodeRewriter(NodeRewriter): ...@@ -1446,7 +1446,7 @@ class SubstitutionNodeRewriter(NodeRewriter):
return f"{self.op1} -> {self.op2}" return f"{self.op1} -> {self.op2}"
class OpRemove(NodeRewriter): class RemovalNodeRewriter(NodeRewriter):
""" """
Removes all applications of an `Op` by transferring each of its Removes all applications of an `Op` by transferring each of its
outputs to the corresponding input. outputs to the corresponding input.
...@@ -3178,6 +3178,11 @@ DEPRECATED_NAMES = [ ...@@ -3178,6 +3178,11 @@ DEPRECATED_NAMES = [
"`OpSub` is deprecated: use `SubstitutionNodeRewriter` instead.", "`OpSub` is deprecated: use `SubstitutionNodeRewriter` instead.",
SubstitutionNodeRewriter, SubstitutionNodeRewriter,
), ),
(
"OpRemove",
"`OpRemove` is deprecated: use `RemovalNodeRewriter` instead.",
RemovalNodeRewriter,
),
] ]
......
...@@ -29,7 +29,7 @@ from aesara.graph.op import compute_test_value, get_test_value ...@@ -29,7 +29,7 @@ from aesara.graph.op import compute_test_value, get_test_value
from aesara.graph.opt import ( from aesara.graph.opt import (
GraphRewriter, GraphRewriter,
NodeRewriter, NodeRewriter,
OpRemove, RemovalNodeRewriter,
Rewriter, Rewriter,
check_chain, check_chain,
copy_stack_trace, copy_stack_trace,
...@@ -2744,7 +2744,7 @@ def local_reshape_lift(fgraph, node): ...@@ -2744,7 +2744,7 @@ def local_reshape_lift(fgraph, node):
return [e] return [e]
register_canonicalize(OpRemove(tensor_copy), name="remove_tensor_copy") register_canonicalize(RemovalNodeRewriter(tensor_copy), name="remove_tensor_copy")
@node_rewriter(None) @node_rewriter(None)
......
...@@ -270,8 +270,8 @@ FunctionGraph(add(z, mul(true_div(mul(y, x), y), true_div(z, x)))) ...@@ -270,8 +270,8 @@ FunctionGraph(add(z, mul(true_div(mul(y, x), y), true_div(z, x))))
>>> e >>> e
FunctionGraph(add(z, mul(x, true_div(z, x)))) 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: Aesara defines some shortcuts to make :class:`NodeRewriter`\s:
...@@ -281,7 +281,7 @@ 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 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. 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: Removes all uses of ``op`` in the following way:
if ``y = op(x)`` then ``y`` is replaced by ``x``. ``op`` must have as many 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: ...@@ -296,14 +296,14 @@ Aesara defines some shortcuts to make :class:`NodeRewriter`\s:
.. code:: .. code::
from aesara.scalar import identity 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 # Replacing `add` by `mul` (this is not recommended for primarily
# mathematical reasons): # mathematical reasons):
add_to_mul = SubstitutionNodeRewriter(add, mul) add_to_mul = SubstitutionNodeRewriter(add, mul)
# Removing `identity` # Removing `identity`
remove_identity = OpRemove(identity) remove_identity = RemovalNodeRewriter(identity)
# The "simplify" operation we've been defining in the past few # The "simplify" operation we've been defining in the past few
# sections. Note that we need two patterns to account for the # sections. Note that we need two patterns to account for the
...@@ -313,12 +313,12 @@ Aesara defines some shortcuts to make :class:`NodeRewriter`\s: ...@@ -313,12 +313,12 @@ Aesara defines some shortcuts to make :class:`NodeRewriter`\s:
.. note:: .. 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 means that everything we said previously about local optimizers
apply (e.g. they need to be wrapped in a :class:`NavigatorOptimizer`, etc.) 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. or :class:`PatternSub`, it is highly recommended to use them.
.. _unification: .. _unification:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论