Skip to content

Commit

Permalink
docs(frontend): reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
bcm-at-zama committed Sep 20, 2023
1 parent fd8c617 commit 079e70b
Showing 1 changed file with 48 additions and 20 deletions.
68 changes: 48 additions & 20 deletions docs/application-tutorial/game_of_life.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,66 @@
from concrete import fhe

# Constants of the game of life
weights_method_3b_a = np.array([[1, 1, 1], [1, 0, 1], [1, 1, 0]])
weights_method_3b_b = np.array([[0, 0, 0], [0, 0, 0], [0, 0, 1]])
weights_method_3b_a = np.array(
[
[1, 1, 1],
[1, 0, 1],
[1, 1, 0],
]
)
weights_method_3b_b = np.array(
[
[0, 0, 0],
[0, 0, 0],
[0, 0, 1],
]
)
table_next_cell_3b_a = [i if i <= 3 else 4 for i in range(8)]
table_next_cell_3b_b = [i - 1 if i in [2, 3] else 0 for i in range(6)]
table_next_cell_3b_c = [i in [2, 3] for i in range(4)]

weights_method_4b = np.array([[1, 1, 1], [1, 0, 1], [1, 1, 1]])
table_next_cell_3b_c = [int(i in [2, 3]) for i in range(4)]

weights_method_4b = np.array(
[
[1, 1, 1],
[1, 0, 1],
[1, 1, 1],
]
)
table_next_cell_4b_a = [i - 1 if i in [2, 3] else 0 for i in range(9)]
table_next_cell_4b_b = [i in [2, 3] for i in range(4)]

weights_method_5b = np.array([[1, 1, 1], [1, 9, 1], [1, 1, 1]])
table_next_cell_5b = [i in [3, 9 + 2, 9 + 3] for i in range(18)]

weights_method_basic = np.array([[1, 1, 1], [1, 0, 1], [1, 1, 1]])
table_next_cell_basic_a = [i in [3] for i in range(9)]
table_next_cell_basic_b = [i in [2, 3] for i in range(9)]
table_next_cell_4b_b = [int(i in [2, 3]) for i in range(4)]

weights_method_5b = np.array(
[
[1, 1, 1],
[1, 9, 1],
[1, 1, 1],
]
)
table_next_cell_5b = [int(i in [3, 9 + 2, 9 + 3]) for i in range(18)]

weights_method_basic = np.array(
[
[1, 1, 1],
[1, 0, 1],
[1, 1, 1],
]
)
table_next_cell_basic_a = [int(i in [3]) for i in range(9)]
table_next_cell_basic_b = [int(i in [2, 3]) for i in range(9)]


# CP tables
# FIXME: remove the np.array(...).astype(np.int32)) when it works,
# https://github.com/zama-ai/concrete/pull/569#discussion_r1330270163
table_cp_next_cell_3b_a = fhe.LookupTable(table_next_cell_3b_a)
table_cp_next_cell_3b_b = fhe.LookupTable(table_next_cell_3b_b)
table_cp_next_cell_3b_c = fhe.LookupTable(np.array(table_next_cell_3b_c).astype(np.int32))
table_cp_next_cell_3b_c = fhe.LookupTable(table_next_cell_3b_c)

table_cp_next_cell_4b_a = fhe.LookupTable(table_next_cell_4b_a)
table_cp_next_cell_4b_b = fhe.LookupTable(np.array(table_next_cell_4b_b).astype(np.int32))
table_cp_next_cell_4b_b = fhe.LookupTable(table_next_cell_4b_b)

table_cp_next_cell_5b = fhe.LookupTable(np.array(table_next_cell_5b).astype(np.int32))
table_cp_next_cell_5b = fhe.LookupTable(table_next_cell_5b)

table_cp_next_cell_basic_a = fhe.LookupTable(np.array(table_next_cell_basic_a).astype(np.int32))
table_cp_next_cell_basic_b = fhe.LookupTable(np.array(table_next_cell_basic_b).astype(np.int32))
table_cp_next_cell_basic_a = fhe.LookupTable(table_next_cell_basic_a)
table_cp_next_cell_basic_b = fhe.LookupTable(table_next_cell_basic_b)

# Function to workaround the miss of padding in CP
def by_hand_padding(original_grid, res):
Expand Down

0 comments on commit 079e70b

Please sign in to comment.