Skip to content

Commit

Permalink
fix(frontend-python): bits with direct circuit, single bit is precisi…
Browse files Browse the repository at this point in the history
…on 1
  • Loading branch information
rudy-6-4 committed Apr 3, 2024
1 parent 8ed6b01 commit ad76be6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontends/concrete-python/concrete/fhe/extensions/bits.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,18 @@ def evaluator(x, bits): # pylint: disable=redefined-outer-name
return result

if isinstance(self.value, Tracer):
output_value = deepcopy(self.value.output)
direct_single_bit = (
Tracer._is_direct
and isinstance(index, int)
and isinstance(output_value.dtype, Integer)
)
if direct_single_bit:
output_value.dtype.bit_width = 1 # type: ignore[attr-defined]
computation = Node.generic(
"extract_bit_pattern",
[deepcopy(self.value.output)],
deepcopy(self.value.output),
output_value,
evaluator,
kwargs={"bits": index},
)
Expand Down

0 comments on commit ad76be6

Please sign in to comment.