Files
torus/docs/dev/api/torus.fhe.tracing.tracer.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

18 KiB

module torus.fhe.tracing.tracer

Declaration of Tracer class.


class Tracer

Tracer class, to create computation graphs from python functions.

method __init__

__init__(computation: Node, input_tracers: list['Tracer'])

property T

Trace numpy.ndarray.T.


property ndim

Trace numpy.ndarray.ndim.


property shape

Trace numpy.ndarray.shape.


property size

Trace numpy.ndarray.size.


method astype

astype(
    dtype: Union[dtype[Any], NoneType, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any], type['ScalarAnnotation']]
) → Tracer

Trace numpy.ndarray.astype(dtype).


method clip

clip(minimum: Any, maximum: Any) → Tracer

Trace numpy.ndarray.clip().


method dot

dot(other: Any) → Tracer

Trace numpy.ndarray.dot().


method flatten

flatten() → Tracer

Trace numpy.ndarray.flatten().


method reshape

reshape(*newshape: Union[Any, tuple[Any, ]]) → Tracer

Trace numpy.ndarray.reshape(newshape).


method round

round(decimals: int = 0) → Tracer

Trace numpy.ndarray.round().


method sanitize

sanitize(value: Any) → Any

Try to create a tracer from a value.

Args: value (Any): value to use

Returns: Any: resulting tracer


method trace

trace(
    function: Callable,
    parameters: dict[str, ValueDescription],
    is_direct: bool = False,
    location: str = ''
) → Graph

Trace function and create the Graph that represents it.

Args: function (Callable): function to trace

parameters (Dict[str, ValueDescription]): parameters of function to trace e.g. parameter x is an EncryptedScalar holding a 7-bit UnsignedInteger

is_direct (bool, default = False): whether the tracing is done on actual parameters or placeholders

Returns: Graph: computation graph corresponding to function


method transpose

transpose(axes: Optional[tuple[int, ]] = None) → Tracer

Trace numpy.ndarray.transpose().


class Annotation

Base annotation for direct definition.

method __init__

__init__(computation: Node, input_tracers: list['Tracer'])

property T

Trace numpy.ndarray.T.


property ndim

Trace numpy.ndarray.ndim.


property shape

Trace numpy.ndarray.shape.


property size

Trace numpy.ndarray.size.


method astype

astype(
    dtype: Union[dtype[Any], NoneType, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any], type['ScalarAnnotation']]
) → Tracer

Trace numpy.ndarray.astype(dtype).


method clip

clip(minimum: Any, maximum: Any) → Tracer

Trace numpy.ndarray.clip().


method dot

dot(other: Any) → Tracer

Trace numpy.ndarray.dot().


method flatten

flatten() → Tracer

Trace numpy.ndarray.flatten().


method reshape

reshape(*newshape: Union[Any, tuple[Any, ]]) → Tracer

Trace numpy.ndarray.reshape(newshape).


method round

round(decimals: int = 0) → Tracer

Trace numpy.ndarray.round().


method sanitize

sanitize(value: Any) → Any

Try to create a tracer from a value.

Args: value (Any): value to use

Returns: Any: resulting tracer


method trace

trace(
    function: Callable,
    parameters: dict[str, ValueDescription],
    is_direct: bool = False,
    location: str = ''
) → Graph

Trace function and create the Graph that represents it.

Args: function (Callable): function to trace

parameters (Dict[str, ValueDescription]): parameters of function to trace e.g. parameter x is an EncryptedScalar holding a 7-bit UnsignedInteger

is_direct (bool, default = False): whether the tracing is done on actual parameters or placeholders

Returns: Graph: computation graph corresponding to function


method transpose

transpose(axes: Optional[tuple[int, ]] = None) → Tracer

Trace numpy.ndarray.transpose().


class ScalarAnnotation

Base scalar annotation for direct definition.

method __init__

__init__(computation: Node, input_tracers: list['Tracer'])

property T

Trace numpy.ndarray.T.


property ndim

Trace numpy.ndarray.ndim.


property shape

Trace numpy.ndarray.shape.


property size

Trace numpy.ndarray.size.


method astype

astype(
    dtype: Union[dtype[Any], NoneType, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any], type['ScalarAnnotation']]
) → Tracer

Trace numpy.ndarray.astype(dtype).


method clip

clip(minimum: Any, maximum: Any) → Tracer

Trace numpy.ndarray.clip().


method dot

dot(other: Any) → Tracer

Trace numpy.ndarray.dot().


method flatten

flatten() → Tracer

Trace numpy.ndarray.flatten().


method reshape

reshape(*newshape: Union[Any, tuple[Any, ]]) → Tracer

Trace numpy.ndarray.reshape(newshape).


method round

round(decimals: int = 0) → Tracer

Trace numpy.ndarray.round().


method sanitize

sanitize(value: Any) → Any

Try to create a tracer from a value.

Args: value (Any): value to use

Returns: Any: resulting tracer


method trace

trace(
    function: Callable,
    parameters: dict[str, ValueDescription],
    is_direct: bool = False,
    location: str = ''
) → Graph

Trace function and create the Graph that represents it.

Args: function (Callable): function to trace

parameters (Dict[str, ValueDescription]): parameters of function to trace e.g. parameter x is an EncryptedScalar holding a 7-bit UnsignedInteger

is_direct (bool, default = False): whether the tracing is done on actual parameters or placeholders

Returns: Graph: computation graph corresponding to function


method transpose

transpose(axes: Optional[tuple[int, ]] = None) → Tracer

Trace numpy.ndarray.transpose().


class TensorAnnotation

Base tensor annotation for direct definition.

method __init__

__init__(computation: Node, input_tracers: list['Tracer'])

property T

Trace numpy.ndarray.T.


property ndim

Trace numpy.ndarray.ndim.


property shape

Trace numpy.ndarray.shape.


property size

Trace numpy.ndarray.size.


method astype

astype(
    dtype: Union[dtype[Any], NoneType, type[Any], _SupportsDType[dtype[Any]], str, tuple[Any, int], tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], list[Any], _DTypeDict, tuple[Any, Any], type['ScalarAnnotation']]
) → Tracer

Trace numpy.ndarray.astype(dtype).


method clip

clip(minimum: Any, maximum: Any) → Tracer

Trace numpy.ndarray.clip().


method dot

dot(other: Any) → Tracer

Trace numpy.ndarray.dot().


method flatten

flatten() → Tracer

Trace numpy.ndarray.flatten().


method reshape

reshape(*newshape: Union[Any, tuple[Any, ]]) → Tracer

Trace numpy.ndarray.reshape(newshape).


method round

round(decimals: int = 0) → Tracer

Trace numpy.ndarray.round().


method sanitize

sanitize(value: Any) → Any

Try to create a tracer from a value.

Args: value (Any): value to use

Returns: Any: resulting tracer


method trace

trace(
    function: Callable,
    parameters: dict[str, ValueDescription],
    is_direct: bool = False,
    location: str = ''
) → Graph

Trace function and create the Graph that represents it.

Args: function (Callable): function to trace

parameters (Dict[str, ValueDescription]): parameters of function to trace e.g. parameter x is an EncryptedScalar holding a 7-bit UnsignedInteger

is_direct (bool, default = False): whether the tracing is done on actual parameters or placeholders

Returns: Graph: computation graph corresponding to function


method transpose

transpose(axes: Optional[tuple[int, ]] = None) → Tracer

Trace numpy.ndarray.transpose().