---
title: "ClikaRT::ops::mm"
sidebar_label: "mm"
description: "Matrix multiply of two rank-2 tensors, with an optional fused bias and activation epilogue. \\[ \\mathrm{out} = \\mathrm{act}(a\\,b + \\mathrm{bias}) \\] a [M, K] x b [K, N] -> [M, N]."
---

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

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

## mm() {#mm}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`mm`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `other`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `bias` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<`[`Activation`](./index.md#Activation)`>` `activation` `=` `std::nullopt`<br />
)

</div>

Matrix multiply of two rank-2 tensors, with an optional fused bias and activation epilogue.

$$
\mathrm{out} = \mathrm{act}(a\,b + \mathrm{bias})
$$

`a [M, K] x b [K, N] -> [M, N]`. Inputs must be rank-2 (use [`bmm`](./bmm.md#bmm) for batched operands, [`matmul`](./matmul.md#matmul) for the broadcasting general form).

**Parameters**

- `input`: left operand `[M, K]`.
- `other`: right operand `[K, N]`.
- `bias`: optional additive bias, broadcastable to `[M, N]` (e.g. `[N]`).
- `activation`: optional fused epilogue; absent = none.

**Returns:** `[M, N]`, the operands' promoted float dtype.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when either operand is not rank-2 or the inner dims disagree.

```cpp
auto y = ClikaRT::ops::mm(x, W, b, ClikaRT::ops::Activation::Relu);
```

<div class="api-declared">

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

</div>
