---
title: "ClikaRT::nn::GLU"
sidebar_label: "GLU"
description: "Gated linear unit: splits the input in half along dim and multiplies the first half by the sigmoid of the second; the size of dim must be even and the output halves it."
---

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

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

**Header:** `ClikaRT/nn/generated/activation.h`  
**Inherits:** [`ClikaRT::nn::Module`](./Module.md)

Gated linear unit: splits the input in half along dim and multiplies the first half by the sigmoid of the second; the size of dim must be even and the output halves it. The module form of [`ClikaRT::ops::glu`](../ops/glu.md#glu), which documents the full contract (shapes, dtypes, errors); construct once, then call it like a function.

## Member functions

### GLU(GLUOptions) {#GLU}

<div class="api-signature">

`explicit` **`GLU`**([`GLUOptions`](./GLUOptions.md) `options` `=` `{}`)

</div>

Constructs the module from [`options`](./GLU.md#options) (every default when omitted).

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 1179

</div>

### GLU(int64\_t) {#GLU-2}

<div class="api-signature">

`explicit` **`GLU`**(`std::int64_t` `dim`)

</div>

`GLU(dim)`: the positional form of `GLUOptions(dim)`.

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 1181

</div>

### forward() {#forward}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`forward`**([`Tensor`](../Tensor.md) `input`) `const`

</div>

[`forward_impl`](./GLU.md#forward), unwrapped: raises [`ClikaRT::Error`](../Error.md) on failure.

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 1192

</div>

### operator()() {#operator-call}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`operator()`**([`Tensor`](../Tensor.md) `input`) `const`

</div>

Same as [`forward`](./GLU.md#forward).

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 1196

</div>

### options() {#options}

<div class="api-signature">

`const` [`GLUOptions`](./GLUOptions.md)`&` **`options`**() `const`

</div>

The settings this module was constructed with.

<div class="api-declared">

Declared in `ClikaRT/nn/generated/activation.h`, line 1200

</div>
