Skip to content

Commit

Permalink
simplify lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed Apr 15, 2024
1 parent 6b02154 commit 0a1cdb4
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions core/matrix/csr_lookup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,7 @@ struct device_sparsity_lookup {

GKO_ATTRIBUTES GKO_INLINE IndexType lookup_search(IndexType col) const
{
// binary search through the column indices
auto length = row_nnz;
IndexType offset{};
while (length > 0) {
auto half_length = length / 2;
auto mid = offset + half_length;
// this finds the first index with column index >= col
auto pred = local_cols[mid] >= col;
length = pred ? half_length : length - (half_length + 1);
offset = pred ? offset : mid + 1;
}
const auto offset = lookup_search_unsafe(col);
return offset < row_nnz && local_cols[offset] == col
? offset
: invalid_index<IndexType>();
Expand Down

0 comments on commit 0a1cdb4

Please sign in to comment.