Skip to content

Commit

Permalink
fix(frontend): docs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-stoian-zama committed Jan 23, 2025
1 parent e718712 commit af6095d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/dev/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 32 additions & 1 deletion docs/dev/api/concrete.fhe.tfhers.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tfhers module to represent, and compute on tfhers integer values.

---

<a href="../../frontends/concrete-python/concrete/fhe/tfhers/__init__.py#L26"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../frontends/concrete-python/concrete/fhe/tfhers/__init__.py#L27"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_type_from_params`

Expand Down Expand Up @@ -43,3 +43,34 @@ Get a TFHE-rs integer type from TFHE-rs parameters in JSON format.
- <b>`TFHERSIntegerType`</b>: constructed type from the loaded parameters


---

<a href="../../frontends/concrete-python/concrete/fhe/tfhers/__init__.py#L48"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `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:**

- <b>`crypto_param_dict`</b> (Dict): dictionary of TFHE-rs parameters
- <b>`is_signed`</b> (bool): sign of the result type
- <b>`precision`</b> (int): precision of the result type



**Returns:**

- <b>`TFHERSIntegerType`</b>: constructed type from the loaded parameters


15 changes: 2 additions & 13 deletions frontends/concrete-python/examples/tfhers-ml/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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()

0 comments on commit af6095d

Please sign in to comment.