Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TVMScript] More concise T.allocate syntax printing #13830

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/script/printer/tir/stmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable)
.set_dispatch<tir::Allocate>( //
"", [](tir::Allocate stmt, ObjectPath stmt_p, IRDocsifier d) -> Doc {
bool concise = AllowConciseScoping(d);
OccurrenceCounter counter(stmt->buffer_var.get());
counter(stmt->body);
if (counter.count == 1 && IsAllocateDeclBufferPattern(stmt.get())) {
if (IsAllocateDeclBufferPattern(stmt.get())) {
return d->AsDoc(stmt->body, stmt_p->Attr("body"));
}
Array<ExprDoc> args;
Expand Down
7 changes: 3 additions & 4 deletions tests/python/unittest/test_tvmscript_printer_tir.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def test_allocate_with_decl_buffer_sugar():
)


def test_allocate_with_decl_buffer_no_sugar_multi_usage():
def test_allocate_with_decl_buffer_sugar_multi_usage():
with IRBuilder() as ib:
with T.allocate([128, 128], "float32") as buffer_data:
with T.decl_buffer([128, 128], "float32", data=buffer_data) as buffer:
Expand All @@ -352,9 +352,8 @@ def test_allocate_with_decl_buffer_no_sugar_multi_usage():
_assert_print(
obj,
"""
with T.allocate([128, 128], "float32", "global") as v:
buffer = T.decl_buffer((128, 128), data=v)
T.evaluate(v)
with T.decl_buffer((128, 128)) as buffer:
T.evaluate(buffer.data)
""",
)

Expand Down