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

[TensorIR] add TIRTextPrinter support for Block and BlockRealize #7716

Merged
merged 2 commits into from
Mar 22, 2021

Conversation

Hzfengsy
Copy link
Member

Currently, there are three printers for TIR:

  1. ReprPrinter: Text printer for stmt node. (e.g. print(for_loop))
  2. TIRTextPrinter: Text printer for function or module. (e.g. print(prim_func))
  3. TVMScriptPrinter: Python syntax printer for function or module.

Note that TIRTextPrinter and TVMScriptPrinter are designed for round-trip printing and parsing, which may contain necessary info for reconstructing the AST (TIRTextPrinter is designed for it but has not supported now). In this PR, I add TIRTextPrinter support for Block and BlockRealize. Then all three printers and one parser (TVMScriptParser) support TensorIR.

Example

#[version = "0.0.5"]
primfn() -> () {
  block([16, tir.reduce_axis(0, 16)], "block") as [vx, vy] {
    bind(vx, x)
    bind(vy, y)
    tir.reads([buffer[vx, vy]])
    tir.writes([buffer_2[vx]])
    tir.attrs({"attr_key": "attr_value"})
    buffer_4 = alloc_buffer(float32[16, 16])
    buffer_5 = match_buffer_region(buffer[0:16, 0:16])
    with init() {
      buffer_2[vx] = 0f32
    }
    buffer_2[vx] = (buffer_2[vx] + buffer[vx, vy])
}

cc @tqchen @junrushao1994

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.

LGTM

Co-authored-by: Junru Shao <junrushao1994@gmail.com>
@tqchen tqchen merged commit 4b528de into apache:main Mar 22, 2021
@Hzfengsy Hzfengsy deleted the TIRTextPrinter branch March 22, 2021 14:18
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request May 6, 2021
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request May 11, 2021
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.

3 participants