Skip to content

Commit

Permalink
fix(gpu): fix cornercase in match value function
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermo-oyarzun authored and agnesLeroy committed Jan 9, 2025
1 parent 6fb1332 commit d2a3450
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tfhe/src/integer/gpu/server_key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ impl CudaServerKey {
if clear == Clear::MAX {
Clear::BITS
} else {
(clear + Clear::ONE).ceil_ilog2() as usize
let bits = (clear + Clear::ONE).ceil_ilog2() as usize;
if bits == 0 {
1
} else {
bits
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions tfhe/src/integer/gpu/server_key/radix/vector_find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ impl CudaServerKey {
selectors: &[CudaBooleanBlock],
streams: &CudaStreams,
) -> CudaUnsignedRadixCiphertext {
if selectors.is_empty() {
return self.create_trivial_radix(0, 1, streams);
}
let packed_list = CudaLweCiphertextList::from_vec_cuda_lwe_ciphertexts_list(
selectors
.iter()
Expand All @@ -46,6 +49,9 @@ impl CudaServerKey {
where
T: CudaIntegerRadixCiphertext,
{
if radixes.is_empty() {
return self.create_trivial_radix(0, 1, streams);
}
let packed_list = CudaLweCiphertextList::from_vec_cuda_lwe_ciphertexts_list(
radixes.iter().map(|ciphertext| &ciphertext.d_blocks),
streams,
Expand Down

0 comments on commit d2a3450

Please sign in to comment.