Skip to content

Commit

Permalink
fix(hlapi): rework CompressedCiphertextListBuilder
Browse files Browse the repository at this point in the history
The hlapi builder target device was selected depending on
features (gpu enabled ? gpu : cpu), but if at `build`
time the thread_local key did not match the expected device,
an error would be returned.

This is a bit too limiting for users that might want to do some
processing on GPU and compression on CPU.

So the Builder is changed to delay, the selection of device used
to compress when `build` is called.
This new design is more flexible for end users, at the cost of a
bit more memory copies

* There should be no API breaking change
* There is no serialization breaking change as only the builder
  (which is not serializable) has been changed
  • Loading branch information
tmontaigu committed Nov 19, 2024
1 parent 015b11d commit 41f8dd1
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 246 deletions.
12 changes: 0 additions & 12 deletions tfhe/src/high_level_api/booleans/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,6 @@ impl InnerBoolean {
}
}

/// Returns the inner cpu ciphertext if self is on the CPU, otherwise, returns a copy
/// that is on the CPU
pub(crate) fn into_cpu(self) -> BooleanBlock {
match self {
Self::Cpu(ct) => ct,
#[cfg(feature = "gpu")]
Self::Cuda(ct) => {
with_thread_local_cuda_streams(|streams| ct.to_boolean_block(streams))
}
}
}

#[cfg(feature = "gpu")]
pub(crate) fn into_gpu(
self,
Expand Down
Loading

0 comments on commit 41f8dd1

Please sign in to comment.