4.6 KiB
module concrete.fhe.mlir.utils
Declaration of various functions and constants related to MLIR conversion.
Global Variables
- MAXIMUM_TLU_BIT_WIDTH
function flood_replace_none_values
flood_replace_none_values(table: list)
Use flooding algorithm to replace None values.
Args:
table (list): the list in which there are None values that need to be replaced with copies of the closest non None data from the list
function construct_table_multivariate
construct_table_multivariate(node: Node, preds: List[Node]) → List[Any]
Construct the lookup table for a multivariate node.
Args: node (Node): Multivariate node to construct the table for
preds (List[Node]): ordered predecessors to node
Returns:
List[Any]: lookup table corresponding to node and its input value
function construct_table
construct_table(
node: Node,
preds: List[Node],
configuration: Configuration
) → List[Any]
Construct the lookup table for an Operation.Generic node.
Args: node (Node): Operation.Generic to construct the table
preds (List[Node]): ordered predecessors to node
configuration (Configuration): configuration to use
Returns:
List[Any]: lookup table corresponding to node and its input value
function construct_deduplicated_tables
construct_deduplicated_tables(
node: Node,
preds: List[Node],
configuration: Configuration
) → Tuple[Tuple[ndarray, Optional[List[Tuple[int, ]]]], ]
Construct lookup tables for each cell of the input for an Operation.Generic node.
Args: node (Node): Operation.Generic to construct the table
preds (List[Node]): ordered predecessors to node
configuration (Configuration): configuration to use
Returns: Tuple[Tuple[numpy.ndarray, List[Tuple[int, ...]]], ...]: tuple containing tuples of 2 for - constructed table - list of indices of the input that use the constructed table
e.g.,
.. code-block: : python
( (np.array([3, 1, 2, 4]), [(1, 0), (2, 1)]), (np.array([5, 8, 6, 7]), [(0, 0), (0, 1), (1, 1), (2, 0)]), )
means the lookup on 3x2 input will result in
.. code-block: : python
[ [5, 8, 6, 7][input[0, 0]] , [5, 8, 6, 7][input[0, 1]] ] [ [3, 1, 2, 4][input[1, 0]] , [5, 8, 6, 7][input[1, 1]] ] [ [5, 8, 6, 7][input[2, 0]] , [3, 1, 2, 4][input[2, 1]] ]
class HashableNdarray
HashableNdarray class, to use numpy arrays in dictionaries.
method __init__
__init__(array: ndarray)
class Comparison
Comparison enum, to store the result comparison in 2-bits as there are three possible outcomes.