Files
torus/docs/dev/api/torus.fhe.mlir.converter.md
zeekay f968edf75a Rename the Concrete dialect and project identifiers to Torus
The MLIR dialect, its conversion passes (TFHEToConcrete, ConcreteToCAPI,
ConcreteToLLVM), the optimizer component, the compiler binary, the Rust
crate and the program_info parameter file all still carried the upstream
project's name. They now carry this one's.

Two things deliberately keep the word, because in them it is not the name.
mlir::OpTrait CRTP parameters mean "the derived type", so they are spelled
Derived and OpTy — LLVM's other conventional spelling for the same idiom.
concreteShape is a capnp field: renaming it would change the serialized
protocol, and the prose describing it is ordinary English.

This also repairs references the earlier partial rename left dangling:
Security.cpp included concrete/curves.gen.h and the directory is torus/,
torus-cpu.h included concrete-num_complex.h, the Torus dialect CMakeLists
named ConcreteOps.td, and compiler/setup.py asked find_namespace_packages
for a "concrete" package that no longer exists — so it built without the
package it ships.
2026-08-27 13:17:38 -07:00

22 KiB

module torus.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,
    composition_rules: Optional[Iterable[CompositionRule]] = None
)

method add

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

method amax

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

method amin

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

method array

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

method assign_dynamic

assign_dynamic(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) → Module

Convert a computation graph to MLIR.

Args: graph (Graph): graph to convert

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

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_dynamic

index_dynamic(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 max

max(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 min

min(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 tfhers_from_native

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

method tfhers_to_native

tfhers_to_native(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