Files
torus/docs/dev/api/torus.fhe.extensions.convolution.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.6 KiB

module torus.fhe.extensions.convolution

Tracing and evaluation of convolution.

Global Variables

  • SUPPORTED_AUTO_PAD

function conv

conv(
    x: Union[ndarray, Tracer],
    weight: Union[ndarray, list, Tracer],
    bias: Optional[ndarray, list, Tracer] = None,
    pads: Optional[tuple[int, ], list[int]] = None,
    strides: Optional[tuple[int, ], list[int]] = None,
    dilations: Optional[tuple[int, ], list[int]] = None,
    kernel_shape: Optional[tuple[int, ], list[int]] = None,
    group: int = 1,
    auto_pad: str = 'NOTSET'
) → Union[ndarray, Tracer]

Trace and evaluate convolution operations.

Refer to https://github.com/onnx/onnx/blob/main/docs/Operators.md#Conv for more info.

Args:

  • x (Union[np.ndarray, Tracer]): input of shape (N, C, D1, ..., DN)
  • weight (Union[np.ndarray, Tracer]): kernel of shape (F, C / group, K1, ..., KN)
  • bias (Optional[Union[np.ndarray, Tracer]], optional): bias of shape (F,). Defaults to None. pads (Optional[Union[Tuple[int, ...], List[int]]], optional): padding for the beginning and ending along each spatial axis (D1_begin, D2_begin, ..., D1_end, D2_end, ...). Will be set to 0 along each spatial axis if not set. strides (Optional[Union[Tuple[int, ...], List[int]]], optional): stride along each spatial axis. Will be set to 1 along each spatial axis if not set. dilations (Optional[Union[Tuple[int, ...], List[int]]], optional): dilation along each spatial axis. Will be set to 1 along each spatial axis if not set. kernel_shape (Optional[Union[Tuple[int, ...], List[int]]], optional): shape of the convolution kernel. Inferred from input weight if not present group (int, optional): number of groups input channels and output channels are divided into. Defaults to 1.
  • auto_pad (str, optional): padding strategy. Defaults to "NOTSET".

Raises:

  • ValueError: if arguments are not appropriate
  • TypeError: unexpected types
  • NotImplementedError: a convolution that we don't support

Returns:

  • Union[np.ndarray, Tracer]: evaluation result or traced computation