From af6095d76a95cb360e6ec798576dc0d5d27d7f70 Mon Sep 17 00:00:00 2001 From: Andrei Stoian Date: Thu, 23 Jan 2025 11:31:45 +0100 Subject: [PATCH] fix(frontend): docs --- docs/dev/api/README.md | 1 + docs/dev/api/concrete.fhe.tfhers.md | 33 ++++++++++++++++++- .../examples/tfhers-ml/example.py | 15 ++------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/docs/dev/api/README.md b/docs/dev/api/README.md index 349fec252..fb7482710 100644 --- a/docs/dev/api/README.md +++ b/docs/dev/api/README.md @@ -364,6 +364,7 @@ - [`utils.format_constant`](./concrete.fhe.representation.utils.md): Get the textual representation of a constant. - [`utils.format_indexing_element`](./concrete.fhe.representation.utils.md): Format an indexing element. - [`tfhers.get_type_from_params`](./concrete.fhe.tfhers.md): Get a TFHE-rs integer type from TFHE-rs parameters in JSON format. +- [`tfhers.get_type_from_params_dict`](./concrete.fhe.tfhers.md): Get a TFHE-rs integer type from TFHE-rs parameters in JSON format. - [`bridge.new_bridge`](./concrete.fhe.tfhers.bridge.md): Create a TFHErs bridge from a circuit or module. - [`tracing.from_native`](./concrete.fhe.tfhers.tracing.md): Convert a Concrete integer to the tfhers representation. - [`tracing.to_native`](./concrete.fhe.tfhers.tracing.md): Convert a tfhers integer to the Concrete representation. diff --git a/docs/dev/api/concrete.fhe.tfhers.md b/docs/dev/api/concrete.fhe.tfhers.md index 1d1d7519b..20c3c7d26 100644 --- a/docs/dev/api/concrete.fhe.tfhers.md +++ b/docs/dev/api/concrete.fhe.tfhers.md @@ -14,7 +14,7 @@ tfhers module to represent, and compute on tfhers integer values. --- - + ## function `get_type_from_params` @@ -43,3 +43,34 @@ Get a TFHE-rs integer type from TFHE-rs parameters in JSON format. - `TFHERSIntegerType`: constructed type from the loaded parameters +--- + + + +## function `get_type_from_params_dict` + +```python +get_type_from_params_dict( + crypto_param_dict: Dict, + is_signed: bool, + precision: int +) → TFHERSIntegerType +``` + +Get a TFHE-rs integer type from TFHE-rs parameters in JSON format. + + + +**Args:** + + - `crypto_param_dict` (Dict): dictionary of TFHE-rs parameters + - `is_signed` (bool): sign of the result type + - `precision` (int): precision of the result type + + + +**Returns:** + + - `TFHERSIntegerType`: constructed type from the loaded parameters + + diff --git a/frontends/concrete-python/examples/tfhers-ml/example.py b/frontends/concrete-python/examples/tfhers-ml/example.py index 27c0ea400..75062069a 100644 --- a/frontends/concrete-python/examples/tfhers-ml/example.py +++ b/frontends/concrete-python/examples/tfhers-ml/example.py @@ -4,7 +4,6 @@ import click import numpy as np -from mlir._mlir_libs._concretelang._compiler import RangeRestriction import concrete.fhe as fhe from concrete.fhe import tfhers @@ -18,8 +17,7 @@ ####################################### tfhers_type = tfhers.get_type_from_params( - "/home/stoiana/Private/Work/concrete/frontends/concrete-python/examples/tfhers-ml/" - + TFHERS_PARAMS_FILE, + TFHERS_PARAMS_FILE, is_signed=IS_SIGNED, precision=FHEUINT_PRECISION, ) @@ -94,15 +92,9 @@ def ccompilee(): # Print the number of bits rounded print(f"lsbs_to_remove: {rounder.lsbs_to_remove}") - restriction = RangeRestriction() - # for v in range(8, 14): - # restriction.add_available_glwe_log_polynomial_size(v) - - circuit = compiler.compile(inputset, range_restriction=restriction, p_error=0.1) + circuit = compiler.compile(inputset) tfhers_bridge = tfhers.new_bridge(circuit) - - print(circuit.graph.format()) return circuit, tfhers_bridge @@ -181,7 +173,4 @@ def run(rust_ct: str, output_rust_ct: str, concrete_keyset_path: str): if __name__ == "__main__": - - circuit, tfhers_bridge = ccompilee() - print(circuit.graph.format()) cli()