Skip to content

Commit

Permalink
Improve unpack_bits (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
svilupp authored Jun 18, 2024
1 parent eff6682 commit 4c6a4d0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

### Fixed
## [0.31.1]

### Updated
- Improved the implementation of `RAGTools.unpack_bits` to be faster with fewer allocations.

## [0.31.0]

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PromptingTools"
uuid = "670122d1-24a8-4d70-bfce-740807c42192"
authors = ["J S @svilupp and contributors"]
version = "0.31.0"
version = "0.31.1"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
14 changes: 13 additions & 1 deletion src/Experimental/RAGTools/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,20 @@ binx = unpack_bits(binint)
@assert bin == binx
```
"""
# function unpack_bits(packed_vector::AbstractVector{UInt64})
# return Bool[((x >> i) & 1) == 1 for x in packed_vector for i in 0:63]
# end
function unpack_bits(packed_vector::AbstractVector{UInt64})
return Bool[((x >> i) & 1) == 1 for x in packed_vector for i in 0:63]
n = length(packed_vector)
result = Vector{Bool}(undef, n * 64)
@inbounds @simd for i in 1:n
x = packed_vector[i]
for j in 1:64
result[(i - 1) * 64 + j] = (x & 1) == 1
x >>= 1
end
end
return result
end
function unpack_bits(packed_matrix::AbstractMatrix{UInt64})
num_rows, num_cols = size(packed_matrix)
Expand Down

2 comments on commit 4c6a4d0

@svilupp
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register

Release notes:

Updated

  • Improved the implementation of RAGTools.unpack_bits to be faster with fewer allocations.

Commits

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/109255

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.31.1 -m "<description of version>" 4c6a4d08755f8977269949d9177b05b22dad7d2b
git push origin v0.31.1

Please sign in to comment.