-
Notifications
You must be signed in to change notification settings - Fork 197
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
Add public enum for select-k algorithm selection #2046
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7a647c3
Add a public enum for select-k algorithm selection
benfred 056be93
Merge branch 'branch-24.02' into select_k_enum
benfred e08250c
Merge branch 'branch-24.02' into select_k_enum
benfred 919e192
code review feedback
benfred 11ae577
Merge branch 'select_k_enum' of github.com:benfred/raft into select_k…
benfred 3e536e1
Merge branch 'branch-24.02' into select_k_enum
benfred 9ea98b9
Add docstring about select-k enum values
benfred 5c11b82
Merge branch 'select_k_enum' of github.com:benfred/raft into select_k…
benfred 12ef2e9
Merge branch 'branch-24.02' into select_k_enum
benfred 931a0d6
update copyright
benfred File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
#include <type_traits> | ||
|
||
namespace raft::matrix { | ||
|
||
/** | ||
* @defgroup select_k Batched-select k smallest or largest key/values | ||
* @{ | ||
*/ | ||
|
||
enum class SelectAlgo : uint8_t { | ||
kAuto = 0, | ||
kRadix8bits = 1, | ||
kRadix11bits = 2, | ||
kRadix11bitsExtraPass = 3, | ||
kWarpAuto = 4, | ||
kWarpImmediate = 5, | ||
kWarpFiltered = 6, | ||
kWarpDistributed = 7, | ||
kWarpDistributedShm = 8, | ||
}; | ||
|
||
inline auto operator<<(std::ostream& os, const SelectAlgo& algo) -> std::ostream& | ||
{ | ||
auto underlying_value = static_cast<std::underlying_type<SelectAlgo>::type>(algo); | ||
|
||
switch (algo) { | ||
case SelectAlgo::kAuto: return os << "kAuto=" << underlying_value; | ||
case SelectAlgo::kRadix8bits: return os << "kRadix8bits=" << underlying_value; | ||
case SelectAlgo::kRadix11bits: return os << "kRadix11bits=" << underlying_value; | ||
case SelectAlgo::kRadix11bitsExtraPass: | ||
return os << "kRadix11bitsExtraPass=" << underlying_value; | ||
case SelectAlgo::kWarpAuto: return os << "kWarpAuto=" << underlying_value; | ||
case SelectAlgo::kWarpImmediate: return os << "kWarpImmediate=" << underlying_value; | ||
case SelectAlgo::kWarpFiltered: return os << "kWarpFiltered=" << underlying_value; | ||
case SelectAlgo::kWarpDistributed: return os << "kWarpDistributed=" << underlying_value; | ||
case SelectAlgo::kWarpDistributedShm: return os << "kWarpDistributedShm=" << underlying_value; | ||
default: throw std::invalid_argument("invalid value for SelectAlgo"); | ||
} | ||
} | ||
|
||
/** @} */ // end of group select_k | ||
|
||
} // namespace raft::matrix |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we expand the algorithms here a bit to give a brief summary of what they mean? I expect this API to be used mostly by power users, but I can't imagine even power users (outside of RAFT immediate developers) would be able to use these options without a brief description and summary of why each might be used. It's also a great opportunity to add the "see also" for the air-top-k paper.