Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tm/boolean ifthenelse #1155

Merged
merged 2 commits into from
May 21, 2024
Merged

Tm/boolean ifthenelse #1155

merged 2 commits into from
May 21, 2024

Conversation

tmontaigu
Copy link
Contributor

This adds if_then_else/cmux on BoleanBlock for integer API
and FheBool for HLAPI.

To have the same name for both default version of the API
in integer a trait was introduced.

Ideally we would have wanted to do the boolean cmux in one PBS by
packing data like this (cond * 4) + (if * 2) + else but this
would not respect the max norm2.

BREAKING CHANGE: integer::ServerKey::if_then_else_parallelized requires the
trait ServerKeyDefaultCMux to be in scope.

Fixes #825

This PR also has the commit that creates the prelude

This adds a prelude to integer.

To access blocks from an integer ciphertext, some traits needs to be in scope.

The common way to make it easy for end
users it via a prelude.

```rust
use tfhe::integer::prelude::*;
```
@cla-bot cla-bot bot added the cla-signed label May 17, 2024
@tmontaigu tmontaigu force-pushed the tm/boolean-ifthenelse branch 2 times, most recently from ca55f6a to e304d88 Compare May 17, 2024 09:56
Comment on lines 72 to 143
pub fn if_then_else_parallelized<T>(
fn if_then_else_parallelized(
&self,
condition: &BooleanBlock,
true_ct: &BooleanBlock,
false_ct: &BooleanBlock,
Copy link
Member

Choose a reason for hiding this comment

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

is this one tested ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a docstring

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But the docstrings are inverted 🤦

Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

Just one small question about tests

@tmontaigu tmontaigu force-pushed the tm/boolean-ifthenelse branch 2 times, most recently from 66f5c98 to cdfc783 Compare May 17, 2024 12:49
Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

Thanks :)

@tmontaigu
Copy link
Contributor Author

make pcc 😭

This adds if_then_else/cmux on BoleanBlock for integer API
and FheBool for HLAPI.

To have the same name for both default version of the API
in integer a trait was introduced.

Ideally we would have wanted to do the boolean cmux in one PBS by
packing data like this `(cond * 4) + (if * 2) + else` but this
would not respect the max norm2.

BREAKING CHANGE: integer::ServerKey::if_then_else_parallelized requires the
trait ServerKeyDefaultCMux to be in scope.
@tmontaigu tmontaigu merged commit bad827d into main May 21, 2024
36 checks passed
@tmontaigu tmontaigu deleted the tm/boolean-ifthenelse branch May 21, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

if_then_else_parallelized(c, a, b): Allow a and b to be BooleanBlock
3 participants