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 committed Jan 9, 2025
1 parent f633eed commit ba18961
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 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.len() == 0 {
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.len() == 0 {
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 Expand Up @@ -155,9 +161,8 @@ impl CudaServerKey {
//
// Thus in that case, the returned value is always 0 regardless of ct's value,
// but we still have to see if the input matched something
let zero_ct: CudaUnsignedRadixCiphertext = unsafe {
self.create_trivial_zero_radix_async(num_blocks_to_represent_values, streams)
};
let zero_ct: CudaUnsignedRadixCiphertext =
unsafe { self.create_trivial_zero_radix_async(1, streams) };
let out_block =
self.unchecked_is_at_least_one_comparisons_block_true(&blocks_ct, streams);
return (zero_ct, out_block);
Expand Down

0 comments on commit ba18961

Please sign in to comment.