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] Printer VarTable #12336

Merged
merged 6 commits into from
Aug 13, 2022
Merged

Conversation

yelite
Copy link
Contributor

@yelite yelite commented Aug 8, 2022

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: #11912

cc @junrushao1994 @gbonik

@yelite yelite force-pushed the tunip-irdocisifer-vartable branch 6 times, most recently from 6f46407 to 92c6499 Compare August 12, 2022 02:10
@yelite yelite marked this pull request as ready for review August 12, 2022 03:24
yelite and others added 2 commits August 11, 2022 23:48
Co-authored-by: Junru Shao <jshao@octoml.ai>
Co-authored-by: Greg Bonik <gbonik@octoml.ai>
Copy link
Member

@junrushao junrushao left a 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
Copy link
Member

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!

Copy link
Contributor Author

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.

Copy link
Member

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!

@junrushao junrushao merged commit d33a332 into apache:main Aug 13, 2022
junrushao pushed a commit that referenced this pull request Aug 16, 2022
This PR:

- Adds IRDocsifier

This PR is in draft state because it's branched off from a pending PR #12336

Tracking issue: #11912

Co-authored-by: Greg Bonik <gbonik@octoml.ai>
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
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
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants