mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
docs: add what happens on out of bounds during table lookups, show lookup table with negative values
This commit is contained in:
@@ -9,7 +9,7 @@ In this tutorial, we are going to go over the ways to perform direct table looku
|
||||
```python
|
||||
import concrete.numpy as cnp
|
||||
|
||||
table = cnp.LookupTable([2, 1, 3, 0])
|
||||
table = cnp.LookupTable([2, -1, 3, 0])
|
||||
|
||||
def f(x):
|
||||
return table[x]
|
||||
@@ -24,7 +24,7 @@ results in
|
||||
<!--pytest-codeblocks:skip-->
|
||||
```python
|
||||
circuit.encrypt_run_decrypt(0) == 2
|
||||
circuit.encrypt_run_decrypt(1) == 1
|
||||
circuit.encrypt_run_decrypt(1) == -1
|
||||
circuit.encrypt_run_decrypt(2) == 3
|
||||
circuit.encrypt_run_decrypt(3) == 0
|
||||
```
|
||||
@@ -68,7 +68,13 @@ circuit.encrypt_run_decrypt(3) == 1
|
||||
circuit.encrypt_run_decrypt(4) == 2
|
||||
```
|
||||
|
||||
Lastly, a `LookupTable` can have any number of elements, let's call it **N**, as long as the lookup variable is in range [-**N**, **N**). Note that, number of elements in the lookup table doesn't affect the performance in any way.
|
||||
Lastly, a `LookupTable` can have any number of elements, let's call it **N**, as long as the lookup variable is in range [-**N**, **N**). If you go out of bounds of this range, you will get the following error:
|
||||
|
||||
```
|
||||
IndexError: index 10 is out of bounds for axis 0 with size 6
|
||||
```
|
||||
|
||||
Note that, number of elements in the lookup table doesn't affect the performance in any way.
|
||||
|
||||
## Direct multi table lookup
|
||||
|
||||
|
||||
Reference in New Issue
Block a user