diff --git a/tfhe/src/integer/gpu/server_key/mod.rs b/tfhe/src/integer/gpu/server_key/mod.rs index 4493e2d9bc..2e67533ff6 100644 --- a/tfhe/src/integer/gpu/server_key/mod.rs +++ b/tfhe/src/integer/gpu/server_key/mod.rs @@ -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 + } } } diff --git a/tfhe/src/integer/gpu/server_key/radix/vector_find.rs b/tfhe/src/integer/gpu/server_key/radix/vector_find.rs index da1cf63475..89fe57bd50 100644 --- a/tfhe/src/integer/gpu/server_key/radix/vector_find.rs +++ b/tfhe/src/integer/gpu/server_key/radix/vector_find.rs @@ -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() @@ -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,