Skip to content

Latest commit

 

History

History
856 lines (393 loc) · 21.5 KB

concrete.fhe.mlir.converter.md

File metadata and controls

856 lines (393 loc) · 21.5 KB

module concrete.fhe.mlir.converter

Declaration of Converter class.

Global Variables

  • MAXIMUM_TLU_BIT_WIDTH

class Converter

Converter class, to convert a computation graph to MLIR.

method __init__

__init__(configuration: Configuration)

method add

add(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method array

array(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method assign_static

assign_static(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method bitwise_and

bitwise_and(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method bitwise_or

bitwise_or(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method bitwise_xor

bitwise_xor(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method broadcast_to

broadcast_to(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method concatenate

concatenate(ctx: Context, node: Node, preds: List[Conversion])

method constant

constant(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method conv1d

conv1d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method conv2d

conv2d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method conv3d

conv3d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method convert

convert(
    graph: Graph,
    mlir_context: <locals>Context,
    name: str = 'main'
) → Module

Convert a computation graph to MLIR.

Args: graph (Graph): graph to convert

mlir_context (MlirContext): MLIR Context to use for module generation

name (str): name of the function to convert

Return: MlirModule: In-memory MLIR module corresponding to the graph


method convert_many

convert_many(graphs: Dict[str, Graph], mlir_context: <locals>Context) → Module

Convert multiple computation graphs to an MLIR module.

Args: graphs (Dict[str, Graph]): graphs to convert

mlir_context (MlirContext): MLIR Context to use for module generation

Return: MlirModule: In-memory MLIR module corresponding to the graph


method copy

copy(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method dot

dot(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method dynamic_tlu

dynamic_tlu(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method equal

equal(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method expand_dims

expand_dims(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method extract_bit_pattern

extract_bit_pattern(
    ctx: Context,
    node: Node,
    preds: List[Conversion]
) → Conversion

method greater

greater(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method greater_equal

greater_equal(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method identity

identity(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method index_static

index_static(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method left_shift

left_shift(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method less

less(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method less_equal

less_equal(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method matmul

matmul(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method maximum

maximum(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method maxpool1d

maxpool1d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method maxpool2d

maxpool2d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method maxpool3d

maxpool3d(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method minimum

minimum(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method multiply

multiply(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method negative

negative(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method node

node(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

Convert a computation graph node into MLIR.

Args: ctx (Context): conversion context

node (Node): node to convert

preds (List[Conversion]): conversions of ordered predecessors of the node

Return: Conversion: conversion object corresponding to node


method not_equal

not_equal(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method ones

ones(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method process

process(graphs: Dict[str, Graph])

Process a computation graph for MLIR conversion.

Args: graphs (Dict[str, Graph]): graphs to process


method relu

relu(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method reshape

reshape(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method right_shift

right_shift(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method round_bit_pattern

round_bit_pattern(
    ctx: Context,
    node: Node,
    preds: List[Conversion]
) → Conversion

method simplify_tag

simplify_tag(configuration: Configuration, tag: str) → str

Keep only n higher tag parts.


method squeeze

squeeze(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method stdout_with_ansi_support

stdout_with_ansi_support() → bool

Detect if ansi characters can be used (e.g. not the case in notebooks).


method subtract

subtract(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method sum

sum(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method tlu

tlu(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

classmethod tlu_adjust

tlu_adjust(table, variable_input, target_bit_width, clipping, reduce_precision)

classmethod trace_progress

trace_progress(
    configuration: Configuration,
    progress_index: int,
    nodes: List[Node]
)

Add a trace_message for progress.

Args: configuration: configuration for title, tags options

progress_index: index of the next node to process

nodes: all nodes


method transpose

transpose(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method truncate_bit_pattern

truncate_bit_pattern(
    ctx: Context,
    node: Node,
    preds: List[Conversion]
) → Conversion

method where

where(ctx: Context, node: Node, preds: List[Conversion]) → Conversion

method zeros

zeros(ctx: Context, node: Node, preds: List[Conversion]) → Conversion