Skip to content

Commit

Permalink
chore: update v1
Browse files Browse the repository at this point in the history
  • Loading branch information
kcelia committed Jan 23, 2024
1 parent 07b2f2a commit 7fddece
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
8 changes: 3 additions & 5 deletions src/concrete/ml/sklearn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@
# However, for internal testing purposes, we retain the capability to disable this feature
os.environ["TREES_USE_ROUNDING"] = os.environ.get("TREES_USE_ROUNDING", "1")

# By default, the decision of the tree ensembles is made in clear
TREES_USE_FHE_SUM = False

# pylint: disable=too-many-public-methods


Expand Down Expand Up @@ -1313,6 +1310,7 @@ def __init__(self, n_bits: Union[int, Dict[str, int]]):
self._tree_inference: Optional[Callable] = None

#: Wether to perform the sum of the output's tree ensembles in FHE or not.
# By default, the decision of the tree ensembles is made in clear.
self._use_fhe_sum = False

BaseEstimator.__init__(self)
Expand All @@ -1327,11 +1325,11 @@ def use_fhe_sum(self) -> bool:
return self._use_fhe_sum

@use_fhe_sum.setter
def use_fhe_sum(self, value) -> None:
def use_fhe_sum(self, value: bool) -> None:
"""Property setter for `use_fhe_sum`.
Args:
value (int): Whether to enable or disable the feature.
value (bool): Whether to enable or disable the feature.
"""

assert isinstance(value, bool), "Value must be a boolean type"
Expand Down
16 changes: 8 additions & 8 deletions src/concrete/ml/sklearn/tree_to_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def add_transpose_after_last_node(onnx_model: onnx.ModelProto, use_fhe_sum: bool
Args:
onnx_model (onnx.ModelProto): The ONNX model.
use_fhe_sum (bool): This parameter is exclusively used to tree-based models.
It determines whether the sum of the trees' outputs is computed in FHE.
use_fhe_sum (bool): Determines whether the sum of the trees' outputs is computed in FHE.
Default to False.
"""
# Get the output node
output_node = onnx_model.graph.output[0]
Expand Down Expand Up @@ -230,8 +230,8 @@ def tree_onnx_graph_preprocessing(
framework (str): The framework from which the ONNX model is generated.
(options: 'xgboost', 'sklearn')
expected_number_of_outputs (int): The expected number of outputs in the ONNX model.
use_fhe_sum (bool): This parameter is exclusively used to tree-based models.
It determines whether the sum of the trees' outputs is computed in FHE.
use_fhe_sum (bool): Determines whether the sum of the trees' outputs is computed in FHE.
Default to False.
"""
# Make sure the ONNX version returned by Hummingbird is OPSET_VERSION_FOR_ONNX_EXPORT
onnx_version = get_onnx_opset_version(onnx_model)
Expand Down Expand Up @@ -339,10 +339,10 @@ def tree_to_numpy(
Args:
model (Callable): The tree model to convert.
x (numpy.ndarray): The input data.
use_rounding (bool): This parameter is exclusively used to tree-based models.
It determines whether the rounding feature is enabled or disabled.
use_fhe_sum (bool): This parameter is exclusively used to tree-based models.
It determines whether the sum of the trees' outputs is computed in FHE.
use_rounding (bool): Determines whether the rounding feature is enabled or disabled.
Default to True.
use_fhe_sum (bool): Determines whether the sum of the trees' outputs is computed in FHE.
Default to False.
framework (str): The framework from which the ONNX model is generated.
(options: 'xgboost', 'sklearn')
output_n_bits (int): The number of bits of the output. Default to 8.
Expand Down

0 comments on commit 7fddece

Please sign in to comment.