Skip to content

Commit 79afb87

Browse files
authored
[rewriter] Remove generic pattern matcher (#2567)
It is obsolete and the capability is covered by the simple pattern matcher. --------- Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent 3156bed commit 79afb87

File tree

6 files changed

+1
-1375
lines changed

6 files changed

+1
-1375
lines changed

.lintrunner.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ exclude_patterns = [
5757
'onnxscript/rewriter/onnxruntime/transformers/multihead_attention.py', # FIXME
5858
'onnxscript/tools/function_unittest_producer.py', # FIXME
5959
'onnxscript/rewriter/onnxruntime/transformers/layernorm.py', # FIXME
60-
'onnxscript/rewriter/generic_pattern.py', # FIXME
6160
]
6261
command = [
6362
'python',

examples/pattern_rewriting.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -141,28 +141,3 @@ def rotary_apply_pattern(op, x, pos_ids, axis):
141141
rule = pattern.RewriteRule(rotary_match_pattern, rotary_apply_pattern, verbose=10)
142142

143143
rule.apply_to_model(ir_model)
144-
145-
# TODO(rama): Update the following, the trace-printed looks different now.
146-
147-
######################################
148-
# The logs shows every time the algorithm rejected a pattern.
149-
# We can see the following:
150-
#
151-
# ::
152-
#
153-
# [OnnxGenericPattern.match] NONE - line: 673:onnxscript.rewriter.generic_pattern, op_type=Cast
154-
# --hint--: BACKWARD: different node types
155-
# --pattern
156-
# ConcatTraining(transpose, transpose) -> (output, length)
157-
# -- model
158-
# ConcatTrainingBad(_onx_transpose0, _onx_transpose0) -> (_onx_concattraining0, _onx_concattraining1)
159-
# iteration=1
160-
# --marked-- #2
161-
# Cast(_onx_cos0) ~ Cast(cos) [140186194226496-140186194222320]
162-
# Cos(_onx_concattraining0) ~ Cos(output) [140186194230816-140186194223472]
163-
# len(stacked)=0:[]
164-
#
165-
# Line 673 in file `generic_pattern.py`, the match was rejected.
166-
# It says while comparing two nodes in the backward direction,
167-
# node types do not match.
168-
# It also says that two nodes were actually matched.

onnxscript/rewriter/_rewrite_rule.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,7 @@ def __init__(
8282
if isinstance(matcher, _matcher.PatternMatcher):
8383
self._matcher = matcher
8484
elif matcher is None:
85-
if target_pattern.has_single_output_node:
86-
self._matcher = _matcher.SimplePatternMatcher(self._target_pattern)
87-
else:
88-
import onnxscript.rewriter.generic_pattern as generic_pattern
89-
90-
self._matcher = generic_pattern.GenericPatternMatcher(self._target_pattern)
85+
self._matcher = _matcher.SimplePatternMatcher(self._target_pattern)
9186
else:
9287
self._matcher = matcher(self._target_pattern)
9388
self._verbose = verbose

0 commit comments

Comments
 (0)