-
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
[TVMScript] Printer VarTable #12336
[TVMScript] Printer VarTable #12336
Conversation
6f46407
to
92c6499
Compare
92c6499
to
571c88c
Compare
Co-authored-by: Junru Shao <jshao@octoml.ai> Co-authored-by: Greg Bonik <gbonik@octoml.ai>
571c88c
to
4a33a98
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.
Overall LGTM. Just a quick question I'm curious about
* than IdDoc. It's useful when a variable is implicitly defined without a name, like | ||
* the buf->data in TIR, which should be mapped to `AttrDoc(IdDoc("<buffer_name>"), "data")`. | ||
* | ||
* This function takes a DocFactory instead of Doc. It's because GetVarDoc needs to |
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 make sure I fully comprehend, would you mind elaborating a little bit with a short example? Thanks a lot!
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.
Sure. Assume DefineByDoc
accepts a Doc
instead of std::function<Doc()>
. It will be more difficult to handle case like
c[k] = a[i] + a[j]
when we call the GetVarDoc
for the first a
and second a
, we expect the returned Docs to be different objects and have different source_path
. Therefore the VarTable
needs to hold a function that returns Doc, rather than Doc itself.
I also update the doc, trying to better clarify it. Let me know if it still looks confusing.
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.
That makes sense to me! Thanks for your detailed explanation!
This PR: - Adds VarTable for the new TVMScript Printer Compared to the prototype version, this: - Removes unnecessary public methods. - GetObjectName - GetUniqueName - Add Frame parameter for `Define` methods. VarTable will add callback to Frame to remove variable when Frame exits. - Changes DocFactory from `ExprDoc(ObjectPath)` to `ExprDoc()` to simplify var definition. Tracking issue: apache#11912
This PR: - Adds IRDocsifier This PR is in draft state because it's branched off from a pending PR apache#12336 Tracking issue: apache#11912 Co-authored-by: Greg Bonik <gbonik@octoml.ai>
This PR:
Compared to the prototype version, this:
Define
methods. VarTable will add callback to Frame to remove variable when Frame exits.ExprDoc(ObjectPath)
toExprDoc()
to simplify var definition.Tracking issue: #11912
cc @junrushao1994 @gbonik