Skip to content

Commit

Permalink
add blank line
Browse files Browse the repository at this point in the history
  • Loading branch information
cyx-6 committed Jan 25, 2023
1 parent faeaa7f commit b9ee9cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/script/printer/doc_printer/python_doc_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,10 @@ String DocToPythonScript(Doc doc, const PrinterConfig& cfg) {
if (cfg->ir_usage.count("relax")) {
headers.push_back(CommentDoc("from tvm.script import relax as " + cfg->relax_prefix));
}
if (headers.size()) {
// Add a blank line between headers and script codes
headers.push_back(CommentDoc(""));
}
printer.Append(StmtBlockDoc(headers));
}
printer.Append(doc, cfg->path_to_underline);
Expand Down
1 change: 1 addition & 0 deletions tests/python/unittest/test_tvmscript_printer_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_ir_module():
"""
# from tvm.script import ir as I
# from tvm.script import tir as T
@I.ir_module
class Module:
@T.prim_func
Expand Down
5 changes: 5 additions & 0 deletions tests/python/unittest/test_tvmscript_printer_tir.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_prim_func():
func,
expected="""
# from tvm.script import tir as T
@T.prim_func
def main(A: T.Buffer((128, 128), "float32"), B: T.Buffer((256, 256), "float32")):
T.evaluate(0)""",
Expand All @@ -64,6 +65,7 @@ def test_prim_func_no_sugar_inlined_buffer():
func,
expected="""
# from tvm.script import tir as T
@T.prim_func
def main(a: T.handle, B: T.Buffer((256, 256), "float32")):
A = T.match_buffer(a, (128, 128))
Expand All @@ -89,6 +91,7 @@ def test_prim_func_no_sugar_shared_buffer_data():
func,
expected="""
# from tvm.script import tir as T
@T.prim_func
def main(a: T.handle, b: T.handle):
A = T.match_buffer(a, (128, 128))
Expand Down Expand Up @@ -703,6 +706,7 @@ def block_with_remap_explicitly():

expected_output = """
# from tvm.script import tir as T
@T.prim_func
def main():
# with T.block("root"):
Expand Down Expand Up @@ -739,6 +743,7 @@ def root_block_explicitly():

expected_output = """
# from tvm.script import tir as T
@T.prim_func
def main():
# with T.block("root"):
Expand Down

0 comments on commit b9ee9cc

Please sign in to comment.