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

Compute topological sort with dynamic key #145

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kaushikcfd
Copy link
Collaborator

Closes #143.

@kaushikcfd kaushikcfd force-pushed the compute_topological_sort_with_dynamic_key branch 3 times, most recently from 839095b to e6374ef Compare June 18, 2022 17:44
@kaushikcfd kaushikcfd marked this pull request as ready for review June 18, 2022 17:48
@kaushikcfd kaushikcfd force-pushed the compute_topological_sort_with_dynamic_key branch from e6374ef to e37fa88 Compare June 18, 2022 17:49
@kaushikcfd kaushikcfd requested a review from inducer June 18, 2022 17:49
@kaushikcfd kaushikcfd force-pushed the compute_topological_sort_with_dynamic_key branch from e37fa88 to fbe9a7a Compare June 19, 2022 20:55
Copy link
Owner

@inducer inducer 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 working on this! While I agree that the operation introduced here is mostly well-defined, the approach seems a bit "brutal". 🙂 The potential $O(n^2)$ cost also points in the same direction. As a result, I'm hesitatnt to cement this into an interface that we might need to support longer term. Maybe just let this live in loopy (where I imagine you're using this) until a more "final" approach emerges.

pytools/graph.py Outdated
self.node = node
self.key = key
node: Any
key: Any
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe introduce type variables for key and node, for increased expressiveness of the type annotation?

Comment on lines +242 to +250
:arg trigger_key_update: A function called after scheduling a node in
*graph* that takes in an instance of :class:`TopologicalOrderState`
corresponding to the scheduling state at that point and returns whether
the comparison keys corresponding to the nodes be updated.

:arg get_key: A callable called when *trigger_key_update*
returns *True*. Takes in an instance of :class:`TopologicalOrderState`
and returns another callable that accepts node as an argument and returns the
comparison key corresponding to the node.
Copy link
Owner

Choose a reason for hiding this comment

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

Couldn't this be a single callable that either performs the update or says "I've not done anything"?

@kaushikcfd kaushikcfd force-pushed the compute_topological_sort_with_dynamic_key branch from fbe9a7a to eaafc94 Compare July 4, 2022 21:01
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.

[Feature-request] Topological sort with keying function that exposes internal state
2 participants