Skip to content

Commit 25a0e31

Browse files
committed
Use approrpirate well-formed checks TIR/Relax functions
1 parent 4512ea1 commit 25a0e31

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

python/tvm/script/parser/core/entry.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import inspect
1919
from typing import Any, Dict, Union
2020

21+
import tvm
2122
from ....ir.module import IRModule
2223
from ...ir_builder import IRBuilder
2324
from . import doc
@@ -95,22 +96,19 @@ def parse(
9596
ret = builder.get()
9697
# check well-formedness in both Relax and TIR
9798
if check_well_formed:
98-
# (C0415 = import-outside-toplevel. It is necessary here to avoid a circular dependency,
99-
# since importing Relax imports a dependency on the parser)
100-
from ....relax.analysis import well_formed as relax_well_formed # pylint: disable=C0415
101-
from ....tir.analysis import verify_well_formed as tir_well_formed # pylint: disable=C0415
102-
10399
check_ret = ret
104100
if not isinstance(check_ret, IRModule):
105101
check_ret = IRModule.from_expr(ret)
106102

107103
source_ast = source.as_ast()
108104

109-
if not relax_well_formed(ret):
105+
if isinstance(ret, (IRModule, tvm.relax.Function)) and not tvm.relax.analysis.well_formed(
106+
ret
107+
):
110108
parser.report_error(source_ast, err=WELL_FORMED_ERROR_MESSAGE)
111109

112110
try:
113-
tir_well_formed(check_ret)
111+
tvm.tir.analysis.verify_well_formed(check_ret)
114112
except Exception as err: # pylint: disable=broad-exception-caught
115113
parser.report_error(
116114
source_ast,

0 commit comments

Comments
 (0)