---
title: "ClikaRT::ops::geglu"
sidebar_label: "geglu"
description: "GeGLU gated activation over a concatenated gate‖up tensor. \\[ \\mathrm{geglu}(x)_{\\ldots,j} = \\mathrm{gelu}(a_{\\ldots,j})\\cdot b_{\\ldots,j},\\qquad x = [\\,a \\,\\|\\, b\\,] \\text{ along the last dim} \\] The…"
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## geglu() {#geglu}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`geglu`**([`Tensor`](../Tensor.md) `input`, [`GeluMode`](./index.md#GeluMode) `approximate` `=` [`GeluMode::None`](./index.md#GeluMode))

</div>

GeGLU gated activation over a concatenated gate‖up tensor.

$$
\mathrm{geglu}(x)_{\ldots,j} = \mathrm{gelu}(a_{\ldots,j})\cdot b_{\ldots,j},\qquad x = [\,a \,\|\, b\,] \text{ along the last dim}
$$

The input's LAST dimension must be even (`2d`); the output halves it (`d`). `approximate` selects the exact (erf) or tanh GELU for the gate.

**Parameters**

- `input`: `[.., 2d]`; gate `a` first, up `b` second.
- `approximate`: [`GeluMode::None`](./index.md#GeluMode) = exact erf form (default); [`GeluMode::Tanh`](./index.md#GeluMode) = the tanh approximation.

**Throws**

- `ClikaRT::Error`: when the last dimension's size is odd, or when the input's dtype is not served (`code_name()` carries the reason).

**Returns:** `[.., d]` (the input shape with the last dim halved); dtype of `input`.

```cpp
// projection emits [tokens, 2*ffn]; geglu gates down to [tokens, ffn]:
auto h = ClikaRT::ops::geglu(proj);
```

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 752

</div>
