Skip to content

Commit

Permalink
[Doc] Fix Relay pattern rewrite (apache#8425)
Browse files Browse the repository at this point in the history
  • Loading branch information
comaniac authored and ylc committed Jan 13, 2022
1 parent c2517a8 commit 7fcbc6a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/langref/relay_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,15 @@ Pattern Rewriting

If you would like to replace the matched pattern with another subgraph, you can leverage
the ``rewrite`` transformation. Here is an example of rewriting a series of arithmetic operators
with a single batch_norm op:
with a single batch_norm op. The constructor parameter ``require_type`` indicates whether InferType
is required to be run before the callback.

.. code-block:: python
class BatchnormCallback(DFPatternCallback):
# A callback class to rewrite the matched pattern to a batch_norm op.
def __init__(self):
def __init__(self, require_type=False):
super().__init__(require_type)
self.x = wildcard()
self.var = wildcard()
self.mean = wildcard()
Expand Down

0 comments on commit 7fcbc6a

Please sign in to comment.