Skip to content

Commit

Permalink
fix(frontend-python): round_bit_pattern, prevent exactness argument m…
Browse files Browse the repository at this point in the history
…isuse
  • Loading branch information
rudy-6-4 committed Mar 22, 2024
1 parent 7eefc6c commit 933fbe4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class Exactness(IntEnum):
Exactness, to specify for specific operator the implementation preference (default and local).
"""

EXACT = 0
APPROXIMATE = 1
APPROXIMATE = 0
EXACT = 1


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ def round_bit_pattern(

lsbs_to_remove = lsbs_to_remove.lsbs_to_remove

if not isinstance(exactness, Exactness):
msg = "exactness should be of type fhe.Exactness"
raise TypeError(msg)

assert isinstance(lsbs_to_remove, int)

def evaluator(
Expand Down
2 changes: 1 addition & 1 deletion frontends/concrete-python/concrete/fhe/mlir/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def tlu(self, ctx: Context, node: Node, preds: List[Conversion]) -> Conversion:
variable_input.origin.properties["exactness"]
or ctx.configuration.rounding_exactness
)
if exactness == Exactness.APPROXIMATE:
if exactness is Exactness.APPROXIMATE:
# we clip values to enforce input precision exactly as queried
original_bit_width = variable_input.origin.properties["original_bit_width"]
lsbs_to_remove = variable_input.origin.properties["kwargs"]["lsbs_to_remove"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def apply(self, graph: Graph):
exactness = self.rounding_exactness

if original_lsbs_to_remove != 0 and final_lsbs_to_remove == 0:
if exactness != Exactness.APPROXIMATE:
if exactness is not Exactness.APPROXIMATE:
self.replace_with_tlu(graph, node)
continue

Expand Down

0 comments on commit 933fbe4

Please sign in to comment.