Exponential Linear Unit
— unknown status| Operation | ELU (bpd_elu) |
|---|---|
| Formula | f(x) = x if x > 0, else α(exp(x) - 1), α=1.0 |
| Category | Transcendental (exp) |
This is the backend-neutral op_expr fact that specifies the operation. The same term is lowered to LLVM IR, CUDA C, MLIR, and every other backend — one specification, many targets.
op_expr(bpd_elu,
sel(le(var, const(0.0)),
sub(call(exp, var), const(1.0)),
var)).
| Backend | LLVM NVPTX (llvm_nvptx) |
|---|---|
| Target | nvptx |
| Description | LLVM IR targeting NVIDIA PTX (GPU). Compiled with llc for nvptx64, loaded via CUDA driver API. |
This is the actual LLVM IR (NVPTX) emitted by our Prolog/Logtalk toolchain for this operation. Every instruction was generated from a declarative op_expr specification — no hand-written assembly.
; BPD elu: elu(x, alpha=1.0) = x if x > 0, expm1(x) if x <= 0
; Uses expm1f for precision near zero — matches PyTorch MKL
define void @bpd_elu(i32 %n, float* %out, float* %in) {
entry:
%cmp = icmp sgt i32 %n, 0
br i1 %cmp, label %loop, label %exit
loop:
%i = phi i32 [ 0, %entry ], [ %next, %store ]
%idx = sext i32 %i to i64
%inptr = getelementptr float, float* %in, i64 %idx
%x = load float, float* %inptr, align 4
%positive = fcmp ogt float %x, 0.0
br i1 %positive, label %passthrough, label %compute
compute:
%result_neg = call float @expm1f(float %x)
br label %store
passthrough:
br label %store
store:
%result = phi float [ %x, %passthrough ], [ %result_neg, %compute ]
%outptr = getelementptr float, float* %out, i64 %idx
store float %result, float* %outptr, align 4
%next = add i32 %i, 1
%done = icmp sge i32 %next, %n
br i1 %done, label %exit, label %loop
exit:
ret void
}
declare float @expm1f(float)
| Tier | SILVER — 0 ULP, robustness testing pending |
|---|---|
| ULP Divergence | 0 |
| Source Commit | b03bc23f7 |
| Deployment | deployed |
| Measured | 2026-09-25 |
| Hardware | NVIDIA Tesla P4 (enclave GPU) |
| Gate | Output compared to PyTorch reference on identical input tensor. 0 ULP = every floating-point bit matches. |