From 00347324baab47ea75d6994d7936c9ba37512a7d Mon Sep 17 00:00:00 2001 From: Elen Kalda Date: Tue, 7 Sep 2021 13:44:05 +0100 Subject: [PATCH] [Documentation] Document rewrite_once option (#8900) --- docs/langref/relay_pattern.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/langref/relay_pattern.rst b/docs/langref/relay_pattern.rst index 68e77ecfa43e..4682e5aa5b33 100644 --- a/docs/langref/relay_pattern.rst +++ b/docs/langref/relay_pattern.rst @@ -476,6 +476,8 @@ is required to be run before the callback. The function ``def callback(self, pre, post, node_map)`` will be invoked when the rewriter matches ``self.pattern``. ``node_map`` is a dictionary mapping from pattern nodes to matched nodes in the graph. +The callback function will be invoked recursively on the returned pattern until the pattern stops changing. As a result, if ``self.pattern`` matches any part of the graph that the callback returned, the rewriter will run in a loop. If you want to avoid multiple rewrites, you can pass a ``rewrite_once=True`` parameter to the constructor. + Pattern Partitioning ********************