Skip to content

Conversation

@Lunderberg
Copy link
Contributor

If there is a trivial binding of Var = DataflowVar, but the non-dataflow variable is never used outside the dataflow block in which is is declared, then we should keep the name of the upstream DataflowVar, as it is more likely to be the human-readable name (e.g. a function parameter).

If there is a trivial binding of `Var = DataflowVar`, but the
non-dataflow variable is never used outside the dataflow block in
which is is declared, then we should keep the name of the upstream
`DataflowVar`, as it is more likely to be the human-readable
name (e.g. a function parameter).
Copy link
Contributor

@slyubomirsky slyubomirsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice improvement, though there's a significant typo that should be fixed before we merge 😅 Thank you!

// Case 3: DataflowVar = DataflowVar
// Case 4a: Var = DataflowVar, but used outside this DataflowBlock
//
// For these three cases, the trivial binding can be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// For these three cases, the trivial binding can be
// For these four cases, the trivial binding can be

😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off by one errors, my two one nemesis! (Thank you, and fixed.)

// Case 1: Var = Var
// Case 2: DataflowVar = Var
// Case 3: DataflowVar = DataflowVar
// Case 4a: Var = DataflowVar, but used outside this DataflowBlock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Case 4a: Var = DataflowVar, but used outside this DataflowBlock
// Case 4a: Var = DataflowVar, but not used outside this DataflowBlock

It appears the text was copied from case 4b. I also think it would be clearer to write out that it is the var that is not used outside the DF block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, and updated the comment to be more explicit. I've also changed "this DataflowBlock" to "the DataflowBlock containing the binding", since this function is called after the entire function is visited, not during the visit of any specific dataflow block.

Copy link
Contributor

@slyubomirsky slyubomirsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the correction.

@Lunderberg Lunderberg merged commit ceb8e22 into apache:main Mar 27, 2024
@Lunderberg Lunderberg deleted the relax_improve_canonicalize_bindings_dataflow_handling branch March 27, 2024 14:10
thaisacs pushed a commit to thaisacs/tvm that referenced this pull request Apr 3, 2024
…#16783)

* [Relax] Improve CanonicalizeBindings in DataflowVar edge case

If there is a trivial binding of `Var = DataflowVar`, but the
non-dataflow variable is never used outside the dataflow block in
which is is declared, then we should keep the name of the upstream
`DataflowVar`, as it is more likely to be the human-readable
name (e.g. a function parameter).

* Update comment for used/not used Var

* ci bump
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