Files
torus/docs/dev/api/torus.fhe.mlir.processors.process_rounding.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

2.9 KiB

module torus.fhe.mlir.processors.process_rounding

Declaration of ProcessRounding graph processor.


class ProcessRounding

ProcessRounding graph processor, to analyze rounding and support regular operations on it.

method __init__

__init__(rounding_exactness: Exactness)

method apply

apply(graph: Graph)

method process_predecessors

process_predecessors(graph: Graph, node: Node)

Process predecessors of the rounding.


method process_successors

process_successors(graph: Graph, node: Node)

Process successors of the rounding.


method replace_with_tlu

replace_with_tlu(graph: Graph, node: Node)

Replace rounding node with a TLU node that simulates rounding.

This is a special case where:

  • user wanted to remove 1-bits
  • there was an overflow
  • overflow protection was on

Let's say user wanted to remove 1-bit from 3-bits, but there was an overflow:

  • [0, 1, 2, 3, 4, 5, 6, 7] would be mapped to [0, 2, 2, 4, 4, 6, 6, 8]
  • or in the actual implementation [(0)00, (0)01, (0)01, (0)10, (0)10, (0)11, (0)11, (1)00]
  • (first bit is the padding bit, which is overwritten on overflows)
  • so the input is 3-bits and the output needs to be 3-bits to store the result
  • which can't be achieved with rounding
  • so we just replace the rounding with a TLU
  • using the table [0, 2, 2, 4, 4, 6, 6, 8]