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

[Tracking Issue] TVMScript Unified Printer #11912

Closed
23 tasks done
yelite opened this issue Jun 27, 2022 · 0 comments
Closed
23 tasks done

[Tracking Issue] TVMScript Unified Printer #11912

yelite opened this issue Jun 27, 2022 · 0 comments
Labels
tir:printer TIR printer:python/tvm/script, src/printer/tir_text_printer.cc, src/printer/tvmscript_printer.cc type:rfc-tracking RFC progress tracking. Ref: https://github.com/apache/tvm-rfcs

Comments

@yelite
Copy link
Contributor

yelite commented Jun 27, 2022

This issue is to track progress for TVMScript Unified Printer

Part 1: Doc

In each step we will introduce several Doc subclasses and implement the corresponding part in PythonDocPrinter.

Part 2: Core infra

The following items can be worked on in parallel with items from part 1.

The following items depend on items from part 1.

Part 3: IR & TIR

  • IR: MetadataFrame, DefaultFrame, IRModuleFrame
  • IR: entry point function: tvm::script::Script
  • TIR: type.cc, var.cc, buffer.cc
  • TIR: expr.cc
  • TIR: op.cc
  • TIR: stmt.cc
    • AssertStmt
    • Evaluate
    • Store
    • BufferStore
  • TIR: stmt.cc
    • IfThenElse
    • While
    • Prefetch
    • LetStmt
  • TIR: stmt.cc
    • Allocate
    • AttrStmt
  • TIR: stmt.cc
    • For
  • TIR: stmt.cc
    • Block
    • BlockRealize
  • TIR: function.cc
@yelite yelite added the type:rfc-tracking RFC progress tracking. Ref: https://github.com/apache/tvm-rfcs label Jun 27, 2022
junrushao pushed a commit that referenced this issue Jul 7, 2022
This PR addes:
- Doc base class
- DocPrinter base class
- PythonDocPrinter
- LiteralDoc and its support in DocPrinter

Tracking issue: #11912
blackkker pushed a commit to blackkker/tvm that referenced this issue Jul 7, 2022
This PR addes:
- Doc base class
- DocPrinter base class
- PythonDocPrinter
- LiteralDoc and its support in DocPrinter

Tracking issue: apache#11912
junrushao pushed a commit that referenced this issue Jul 13, 2022
Motivation:

Same IR node object can be referenced in several different contexts inside a larger IR object. For example, a variable could be referenced in several statements within a block.

This makes it impossible to use an object pointer to uniquely identify a "location" within the larger IR object for error reporting purposes. The `ObjectPath` class addresses this problem by serving as a unique "locator".

Tracking issue: #11912
masahi pushed a commit to masahi/tvm that referenced this issue Jul 15, 2022
This PR addes:
- Doc base class
- DocPrinter base class
- PythonDocPrinter
- LiteralDoc and its support in DocPrinter

Tracking issue: apache#11912
masahi pushed a commit to masahi/tvm that referenced this issue Jul 15, 2022
Motivation:

Same IR node object can be referenced in several different contexts inside a larger IR object. For example, a variable could be referenced in several statements within a block.

This makes it impossible to use an object pointer to uniquely identify a "location" within the larger IR object for error reporting purposes. The `ObjectPath` class addresses this problem by serving as a unique "locator".

Tracking issue: apache#11912
junrushao pushed a commit that referenced this issue Jul 27, 2022
This PR addes:

- All ExprDoc subclasses
- Their Python bindings
- Support of ExprDoc in PythonDocPrinter
- Unit tests for ExprDoc in PythonDocPrinter

Tracking issue: #11912
junrushao pushed a commit to yelite/tvm that referenced this issue Jul 27, 2022
This PR addes:

- Awareness of expression (operator) precedence during Python code printing
(`(* 1 (+ 2 3))` prints as `1 * (2 + 3)`)

Tracking issue: apache#11912

This PR is in draft state because it's branched off an open PR
apache#12112.
junrushao pushed a commit to yelite/tvm that referenced this issue Jul 27, 2022
This PR addes:

- All StmtDoc subclasses
- Python bindings for StmtDoc

Tracking issue: apache#11912
junrushao pushed a commit to gbonik/tvm that referenced this issue Jul 27, 2022
Motivation: when two IR objects fail a structural equality check, currently there is no easy way to
find out which part of the IR caused the mismatch. In this PR, we modify the `StructuralEqual`
infrastructure to also optionally return a pair of `ObjectPath` objects that point to the mismatch.
(See apache#11977). In the upcoming PRs, we will pass these paths to the
TIR printer, so that it could highlight the mismatch location nicely.

Tracking issue: apache#11912
junrushao pushed a commit that referenced this issue Jul 27, 2022
This PR addes:

- All StmtDoc subclasses
- Python bindings for StmtDoc

Tracking issue: #11912
junrushao pushed a commit that referenced this issue Jul 28, 2022
This PR addes:

- StmtDoc Printing in PythonDocPrinter

Tracking issue: #11912
junrushao pushed a commit to yelite/tvm that referenced this issue Aug 1, 2022
This PR:

- Handle expression (operator) precedence during Python code printing (`(* 1 (+ 2 3))` prints as
`1 * (2 + 3)`)
- Addresses remaining feedback from previous PR apache#12112
- Reformats Python import with isort

Tracking issue: apache#11912
junrushao pushed a commit that referenced this issue Aug 1, 2022
This PR:

- Handle expression (operator) precedence during Python code printing (`(* 1 (+ 2 3))` prints as
`1 * (2 + 3)`)
- Addresses remaining feedback from previous PR #12112
- Reformats Python import with isort

Tracking issue: #11912
junrushao pushed a commit that referenced this issue Aug 3, 2022
Motivation: when two IR objects fail a structural equality check, currently there is no easy way to
find out which part of the IR caused the mismatch. In this PR, we modify the `StructuralEqual`
infrastructure to also optionally return a pair of `ObjectPath` objects that point to the mismatch.
(See #11977). In the upcoming PRs, we will pass these paths to the
TIR printer, so that it could highlight the mismatch location nicely.

Tracking issue: #11912
junrushao pushed a commit that referenced this issue Aug 5, 2022
…12299)

Motivation: when printing a piece of TIR, we need to track an ObjectPath from the root TIR object to the currently printed object. This means that we need a convenient way to maintain an ObjectPath whenever we access a sub-object, e.g. via an attribute.

Tracking issue: #11912
junrushao pushed a commit that referenced this issue Aug 5, 2022
This PR:

- Add the source_paths attribute to Doc base class.
- Add the corresponding Python binding for it.

This PR is depended by multiple tasks, including the diagnostic output in DocPrinter, VarTable and IRDocisifer.

Tracking issue: #11912

Co-authored-by: Greg Bonik <gbonik@octoml.ai>
junrushao pushed a commit that referenced this issue Aug 10, 2022
This PR:

- Adds the registry of printing function (traced_object_layered_functor.cc)

Compared to the prototype version, this:
- Consolidates the implementation into a single class, since this class is only for the TVMScript printer.
- Deduces the TObjectRef when calling set_dispatch.

Tracking issue: #11912

Co-authored-by: Greg Bonik <gbonik@octoml.ai>
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
This PR:

- Handle expression (operator) precedence during Python code printing (`(* 1 (+ 2 3))` prints as
`1 * (2 + 3)`)
- Addresses remaining feedback from previous PR apache#12112
- Reformats Python import with isort

Tracking issue: apache#11912
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
Motivation: when two IR objects fail a structural equality check, currently there is no easy way to
find out which part of the IR caused the mismatch. In this PR, we modify the `StructuralEqual`
infrastructure to also optionally return a pair of `ObjectPath` objects that point to the mismatch.
(See apache#11977). In the upcoming PRs, we will pass these paths to the
TIR printer, so that it could highlight the mismatch location nicely.

Tracking issue: apache#11912
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
…pache#12299)

Motivation: when printing a piece of TIR, we need to track an ObjectPath from the root TIR object to the currently printed object. This means that we need a convenient way to maintain an ObjectPath whenever we access a sub-object, e.g. via an attribute.

Tracking issue: apache#11912
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
This PR:

- Add the source_paths attribute to Doc base class.
- Add the corresponding Python binding for it.

This PR is depended by multiple tasks, including the diagnostic output in DocPrinter, VarTable and IRDocisifer.

Tracking issue: apache#11912

Co-authored-by: Greg Bonik <gbonik@octoml.ai>
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
This PR:

- Adds the registry of printing function (traced_object_layered_functor.cc)

Compared to the prototype version, this:
- Consolidates the implementation into a single class, since this class is only for the TVMScript printer.
- Deduces the TObjectRef when calling set_dispatch.

Tracking issue: apache#11912

Co-authored-by: Greg Bonik <gbonik@octoml.ai>
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
apache#12344)

This adds an ability to print a "diagnostic marker" based on a given ObjectPath. For example, say we are printing a fragment of TIR like
```
for i in T.serial(10):
    a[i] = 5
```
and we would like bring the user's attention to the bound of the loop:
```
for i in T.serial(10):
                  ^^
    a[i] = 5
```
In this case we would give the doc printer an object path that represents this loop bound, i.e. something like `path_to_underline=ObjectPath.root().attr("extent")`

Tracking issue: apache#11912
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
This PR:

- Implement Frame for the TVMScript Unified Printer

Compared to the prototype version, this:

- Removes the dependency of VarTable (SymbolTable) from Frame
- Adds a callback array to the Frame base class so that VarTable can add callback to clean variable when Frame goes out scope

Tracking issue: apache#11912
xinetzone pushed a commit to daobook/tvm that referenced this issue 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 issue 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>
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
This PR:

- Adds an entry point for the TVMScript Unified Printer
- Adds a helper object class `RootNodeContainer` to provide an injection point for the actual printer implementation to add specialized logic on the root node to print.

Tracking issue: apache#11912
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
)

This PR adds boolean operators to OperationDoc. This is needed by the TIR expression printing because it has `tir::And` and `tir::Or`.

Tracking issue: apache#11912
xinetzone pushed a commit to daobook/tvm that referenced this issue Nov 25, 2022
)

This PR is split from apache#12492, to make the necessary updates to the printer infra for future PRs of TIR printer.

Tracking issue: apache#11912

Co-authored-by: Greg Bonik <gbonik@octoml.ai>
@hpanda-naut hpanda-naut added the tir:printer TIR printer:python/tvm/script, src/printer/tir_text_printer.cc, src/printer/tvmscript_printer.cc label Dec 1, 2022
mikeseven pushed a commit to mikeseven/tvm that referenced this issue Sep 27, 2023
This PR addes:
- Doc base class
- DocPrinter base class
- PythonDocPrinter
- LiteralDoc and its support in DocPrinter

Tracking issue: apache#11912
mikeseven pushed a commit to mikeseven/tvm that referenced this issue Sep 27, 2023
Motivation:

Same IR node object can be referenced in several different contexts inside a larger IR object. For example, a variable could be referenced in several statements within a block.

This makes it impossible to use an object pointer to uniquely identify a "location" within the larger IR object for error reporting purposes. The `ObjectPath` class addresses this problem by serving as a unique "locator".

Tracking issue: apache#11912
mikeseven pushed a commit to mikeseven/tvm that referenced this issue Sep 27, 2023
This PR:

- Adds the registry of printing function (traced_object_layered_functor.cc)

Compared to the prototype version, this:
- Consolidates the implementation into a single class, since this class is only for the TVMScript printer.
- Deduces the TObjectRef when calling set_dispatch.

Tracking issue: apache#11912

Co-authored-by: Greg Bonik <gbonik@octoml.ai>
mikeseven pushed a commit to mikeseven/tvm that referenced this issue Sep 27, 2023
apache#12344)

This adds an ability to print a "diagnostic marker" based on a given ObjectPath. For example, say we are printing a fragment of TIR like
```
for i in T.serial(10):
    a[i] = 5
```
and we would like bring the user's attention to the bound of the loop:
```
for i in T.serial(10):
                  ^^
    a[i] = 5
```
In this case we would give the doc printer an object path that represents this loop bound, i.e. something like `path_to_underline=ObjectPath.root().attr("extent")`

Tracking issue: apache#11912
mikeseven pushed a commit to mikeseven/tvm that referenced this issue Sep 27, 2023
This PR:

- Implement Frame for the TVMScript Unified Printer

Compared to the prototype version, this:

- Removes the dependency of VarTable (SymbolTable) from Frame
- Adds a callback array to the Frame base class so that VarTable can add callback to clean variable when Frame goes out scope

Tracking issue: apache#11912
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tir:printer TIR printer:python/tvm/script, src/printer/tir_text_printer.cc, src/printer/tvmscript_printer.cc type:rfc-tracking RFC progress tracking. Ref: https://github.com/apache/tvm-rfcs
Projects
None yet
Development

No branches or pull requests

5 participants