Encrypted ReLU

L4 · Application Components
relu · 1 specification · 2 implementations · 3 benchmarks
WHAT IT ISmax(0, x) for every element of a secret vector — the activation function of deep learning, encrypted.
FHEMLACTIVATIONCHALLENGE
SIGNATURE
kernel relu<type T: Real, N: u32>(
%xs: secret<tensor<N x T>>,
) -> %r: secret<tensor<N x T>>
Sizes and element types are left open here. A specification fixes them; an implementation says over which of them it works.
SPECIFICATIONS1publishedIMPLEMENTATIONS22 measured
BENCHMARKS3across 2 machines
FASTEST446 msN1024 on fherma-general-purpose
CHALLENGES0none opened
DESCRIPTION

Definition

The rectified linear unit applied element by element to a secret vector. For a real vector x=(x0,,xN1)x = (x_0, \ldots, x_{N-1}), the result rr has

ri=max(0,xi)=xi+xi2,0i<N.r_i = \max(0, x_i) = \frac{x_i + |x_i|}{2}, \qquad 0 \le i < N.

Each output element depends only on the corresponding input element. There is no interaction between positions and no reduction across the vector.

Mathematical Domain

ReLU is piecewise linear with a kink at the origin: zero for negative inputs, the identity for positive ones, and not differentiable at zero. Arithmetic homomorphic encryption schemes evaluate only polynomials — additions and multiplications — so the corner cannot be expressed exactly. It is approximated by a polynomial over a bounded input range, and an implementation trades closeness to the kink against multiplicative depth, which is the budget the rest of a network needs.

The kernel fixes neither the arithmetic scheme, the input range, the vector length, nor the packing; these are defined by individual specifications.

Parameters Defined by Specifications

A specification narrows the general ReLU operation into a concrete problem by pinning:

  • the element domain and encryption scheme (for example real values under CKKS)
  • the input range on which the approximation must hold
  • the vector length NN
  • the ciphertext packing and layout
  • the correctness or accuracy rule and how it is scored
  • which stages of the computation are timed

Applications

ReLU is the dominant activation in deep learning. It appears at the end of most layers in convolutional and fully connected networks, so every layer of a private-inference pipeline over such a model needs it. It is also the building block from which max-pooling and other rectifier-based operations are composed.

MAINTAINER
FM
fairmathreviews specifications · resolves disputes
USED BY · 0 KERNELS
Kernels above this one. If this kernel is wrong, or slow, they are wrong or slow with it.Nothing depends on this kernel yet.
BUILDS ON · 0 KERNELS
Kernels this one is stated in terms of. Not a call graph — a statement of dependence between problems.Nothing. This kernel sits at the bottom of the graph.
RECENT ACTIVITYNothing yet.