-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[TIR, TVMScript] Update printer / parser to make T.allocate return buffer var #12412
Conversation
628b844
to
f2a0a1a
Compare
1f07d88
to
45a5ac8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I have a couple of questions on the implementation side, but overall it looks very good!
@@ -100,13 +100,21 @@ class BufferUsageFinder : public StmtExprVisitor { | |||
StmtExprVisitor::VisitStmt_(op); | |||
} | |||
|
|||
void VisitStmt_(const DeclBufferNode* op) final { | |||
buffers_declared_.insert(op->buffer.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also track which buffers have gone out of scope? If I'm understanding it correctly, a single DeclBufferNode
would also allow for usage outside of the DeclBufferNode::body
, where I'd expect it to only apply within the scope of the node.
tests/python/contrib/test_ethosu/test_copy_compute_reordering.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To answer the question about T.allocate
vs T.decl_buffer
update:
There are two ways to update the existing TVM scripts.
- Update
T.allocate
toT.allocate
+T.buffer_decl
. This is strictly equivalent to the TIR before. - Update
T.allocate
toT.allocate
+T.decl_buffer
, (or the syntax sugar form, only a singleT.decl_buffer
statement without data argument). This adds aDeclBuffer
node in TIR, which is not strictly equivalent to the TIR before. This is the preferred way (as it uses explicitDeclBuffer
) but might require updating the existing passes. To minimize changes to existing passes in this PR, in the case this method doesn't work out-of-box, we will choose method 1 for now.
That makes sense for minimizing the changes to the generated TIR, so that those can be handled in an independent change. Marking all of those conversations as resolved. |
45a5ac8
to
071b81d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…ffer var (apache#12412) * Updated TVMScript syntax of `T.allocate` to return buffer var. * Added syntax sugar for `T.decl_buffer`. When `data` field is not specified, `data` will be implicitly created via `Allocate` stmt. * Updated the existing test cases. Most test cases can be updated by changing `T.allocate` to `T.decl_buffer`. `T.allocate` in some tests are updated to `T.allocate` + `T.buffer_decl`, to maintain the legacy behavior of allocation and implicit buffer declaration (will be followed up in future PR to adopt `T.decl_buffer`).
T.allocate
to return buffer var.T.decl_buffer
. Whendata
field is not specified,data
will be implicitly created viaAllocate
stmt.T.allocate
toT.decl_buffer
.T.allocate
in some tests are updated toT.allocate
+T.buffer_decl
, to maintain the legacy behavior of allocation and implicit buffer declaration (will be followed up in future PR to adoptT.decl_buffer
).Related RFC: apache/tvm-rfcs#87
cc @junrushao1994 @Lunderberg @wrongtest-intellif @cyx-6 @tqchen