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

[Relax] Implement relax.transform.TopologicalSort #16697

Merged
merged 2 commits into from
Mar 17, 2024

Conversation

Lunderberg
Copy link
Contributor

This commit implements a utility relax.transform.TopologicalSort, which can re-order the bindings that occur in a
relax.DataflowBlock. This is not intended for use in a general-purpose optimization pipeline, but instead as a utility that may be used as needed in specific cases. For example, normalization of unit tests that should not depend on the order of variable binding.

@Lunderberg Lunderberg force-pushed the relax_topological_sort branch 2 times, most recently from dc6e233 to d976e9d Compare March 15, 2024 20:16
This commit implements a utility `relax.transform.TopologicalSort`,
which can re-order the bindings that occur in a
`relax.DataflowBlock`.  This is not intended for use in a
general-purpose optimization pipeline, but instead as a utility that
may be used as needed in specific cases.  For example, normalization
of unit tests that should not depend on the order of variable binding.
@@ -233,6 +233,29 @@ def ToNonDataflow() -> tvm.ir.transform.Pass:
return _ffi_api.ToNonDataflow() # type: ignore


def TopologicalSort(order="depth-first", direction="from-inputs") -> tvm.ir.transform.Pass:
"""Sort relax.Dataflow blocks
Copy link
Member

Choose a reason for hiding this comment

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

To be more precise, "Sort bindings in relax.Dataflow blocks with the specified order"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, and updated.

@masahi masahi merged commit fbfa926 into apache:main Mar 17, 2024
19 checks passed
@Lunderberg Lunderberg deleted the relax_topological_sort branch March 17, 2024 22:48
thaisacs pushed a commit to thaisacs/tvm that referenced this pull request Apr 3, 2024
* [Relax] Implement relax.transform.TopologicalSort

This commit implements a utility `relax.transform.TopologicalSort`,
which can re-order the bindings that occur in a
`relax.DataflowBlock`.  This is not intended for use in a
general-purpose optimization pipeline, but instead as a utility that
may be used as needed in specific cases.  For example, normalization
of unit tests that should not depend on the order of variable binding.

* Update docstring according to review comment
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.

None yet

2 participants