[go: nahoru, domu]

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

Switch CPU TopK Algorithm to use Floyd-Rivest #5236

Merged
merged 3 commits into from
Jun 21, 2021

Conversation

ahmedsabie
Copy link
Contributor
@ahmedsabie ahmedsabie commented Jun 20, 2021

This updated algorithm runs in expected O(n + k) instead of the existing O(nlogn + k) sort where n is number of elements in array

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

Copy link
Collaborator
@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

great stuff, thanks!

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @ahmedsabie and @lina128)


tfjs-backend-cpu/src/kernels/TopK_impl.ts, line 63 at r1 (raw file):

https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm

might be good to have a dedicated swap method that does this, since it is not obvious that this operation is atomic.

Copy link
Collaborator
@lina128 lina128 left a comment

Choose a reason for hiding this comment

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

Great work, thanks Ahmed! Should WASM update to this too?

Reviewable status: :shipit: complete! 2 of 1 approvals obtained (waiting on @ahmedsabie)

@ahmedsabie ahmedsabie merged commit 8a1fd30 into tensorflow:master Jun 21, 2021
@ahmedsabie ahmedsabie deleted the topk-cpu branch June 21, 2021 23:08
@ahmedsabie
Copy link
Contributor Author

Great work, thanks Ahmed! Should WASM update to this too?

Reviewable status: :shipit: complete! 2 of 1 approvals obtained (waiting on @ahmedsabie)

That's a good idea since it should be faster on there as well, I'll change it for WASM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants