Skip to content

Commit 42a38f3

Browse files
remove unnecessary if else
1 parent fb0555c commit 42a38f3

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

onnxscript/rewriter/pattern.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,13 +1382,10 @@ def try_rewrite(
13821382
if not check_match_result:
13831383
# If check function was provided, but it failed, return the reason for failure to the tracer.
13841384
if isinstance(check_match_result, MatchResult):
1385-
if check_match_result._failure_nodes_and_values:
1386-
match.fail(
1387-
check_match_result.reason,
1388-
check_match_result._failure_nodes_and_values,
1389-
)
1390-
else:
1391-
match.fail(check_match_result.reason)
1385+
match.fail(
1386+
check_match_result.reason,
1387+
check_match_result._failure_nodes_and_values,
1388+
)
13921389
if tracer:
13931390
tracer.log(
13941391
self, graph_or_function, node, match, MatchStatus.CONDITION_FAILED
@@ -1827,18 +1824,9 @@ def print(self):
18271824
print("Graph matching failed.")
18281825
failure_nodes_and_values = self.match_result._failure_nodes_and_values
18291826
print("Failure at or around nodes/values:")
1830-
18311827
if failure_nodes_and_values:
1832-
if isinstance(failure_nodes_and_values, list):
1833-
for failure_cause in failure_nodes_and_values:
1834-
if isinstance(failure_cause, ir.Node):
1835-
failure_cause.display()
1836-
elif isinstance(failure_cause, ir.Value):
1837-
print(failure_cause)
1838-
elif isinstance(failure_nodes_and_values, ir.Node):
1839-
failure_nodes_and_values.display()
1840-
elif isinstance(failure_nodes_and_values, ir.Value):
1841-
print(failure_nodes_and_values)
1828+
for failure_cause in failure_nodes_and_values:
1829+
failure_cause.display()
18421830
print("Matched nodes:")
18431831
import onnxscript.rewriter._ir_utils as ir_utils
18441832

0 commit comments

Comments
 (0)