Skip to content

Commit

Permalink
refactor(integer): use same logic for signed cmps
Browse files Browse the repository at this point in the history
This makes the logic for signed cmps more similar whether the parameters
are 1_1 or higher.

This will make possible to reuse this part of the code for
scalar comparisons
  • Loading branch information
tmontaigu committed Sep 27, 2024
1 parent 81d82bc commit 16feb46
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 170 deletions.
5 changes: 2 additions & 3 deletions tfhe/src/integer/server_key/radix_parallel/cmux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,15 @@ impl ServerKeyDefaultCMux<&BooleanBlock, &BooleanBlock> for ServerKey {
});

let negated_cond = self.boolean_bitnot(condition);

let (mut lhs, rhs) = rayon::join(
|| {
let mut block = self.key.scalar_mul(&condition.0, 2);
let mut block = self.key.unchecked_scalar_mul(&condition.0, 2);
self.key.unchecked_add_assign(&mut block, &true_ct.0);
self.key.apply_lookup_table_assign(&mut block, &zero_lut);
block
},
|| {
let mut block = self.key.scalar_mul(&negated_cond.0, 2);
let mut block = self.key.unchecked_scalar_mul(&negated_cond.0, 2);
self.key.unchecked_add_assign(&mut block, &false_ct.0);
self.key.apply_lookup_table_assign(&mut block, &zero_lut);
block
Expand Down
Loading

0 comments on commit 16feb46

Please sign in to comment.