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] Connect assert_structural_equal with new TVMScript printer #13859

Merged
merged 1 commit into from
Feb 5, 2023

Conversation

cyx-6
Copy link
Contributor

@cyx-6 cyx-6 commented Jan 28, 2023

This PR refactors the output of assert_structural_equal. Different from the directly printing mismatching nodes, in the old version, the improved one will print the whole scripts, with mismatching nodes underlined. And we print the ObjectPath to the mismatching nodes for further better debug. For example, we have following functions

@T.prim_func
def func1(a: T.handle, b: T.handle):
  A = T.match_buffer(a, (128, 128))
  B = T.match_buffer(b, (128, 128))

@T.prim_func
def func2(a: T.handle, b: T.handle):
  A = T.match_buffer(a, (128, 128))
  B = T.match_buffer(b, (128, 256))

the log of assert_structural_equal(func1, func2) will be like

ValueError: StructuralEqual check failed, caused by lhs at <root>.buffer_map[b].shape[1].value:
# from tvm.script import tir as T

@T.prim_func
def main(a: T.handle, b: T.handle):
  A = T.match_buffer(a, (128, 128))
  B = T.match_buffer(b, (128, 128))
                              ^^^
  T.evaluate(0)
and rhs at <root>.buffer_map[b].shape[1].value:
# from tvm.script import tir as T

@T.prim_func
def main(a: T.handle, b: T.handle):
  A = T.match_buffer(a, (128, 128))
  B = T.match_buffer(b, (128, 256))
                              ^^^
  T.evaluate(0)

instead of

ValueError: StructuralEqual check failed, caused by lhs:
128
and rhs:
256

which is not readable sometimes.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 28, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@cyx-6 cyx-6 marked this pull request as draft January 28, 2023 08:46
@cyx-6 cyx-6 marked this pull request as ready for review January 31, 2023 00:22
add additional `ObjectPath` for body

minor fix for `T.match_buffer`

work in progress

fallback printing for `Array` and `Map`

more detailed `ObjectPath` from first mismatches

add fallback for `Script`

add comments of fallback mechanism

fix grammar
@junrushao
Copy link
Member

Thanks @cyx-6 for the PR! A side note: you may note the PR description in the commit message :-)

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.

4 participants