---
title: "ClikaRT::ops::div"
sidebar_label: "div"
description: "Divides input by other elementwise, with an optional quotient rounding. \\[ out = act(round_{mode}(a / other)) \\] Broadcasts and promotes as add. input dividend tensor."
---

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

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

2 overloads.

## div(Tensor, ScalarOrTensor, RoundingMode, Activation) {#div}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`div`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `other`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`RoundingMode`](./index.md#RoundingMode) `rounding_mode` `=` [`RoundingMode::None`](./index.md#RoundingMode),<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Activation`](./index.md#Activation) `activation` `=` [`Activation::Identity`](./index.md#Activation)<br />
)

</div>

Divides `input` by `other` elementwise, with an optional quotient rounding.

$$
out = act(round_{mode}(a / other))
$$

Broadcasts and promotes as [`add`](./add.md#add).

**Parameters**

- `input`: dividend tensor.
- `other`: divisor: tensor or scalar literal.
- `rounding_mode`: [`RoundingMode::None`](./index.md#RoundingMode) (default) is true division; `Trunc` rounds the quotient toward zero; `Floor` toward `-inf` ([`ops::floor_divide`](./floor_divide.md#floor_divide) is exactly [`div`](./div.md#div) with `Floor`).
- `activation`: fused float-only epilogue applied AFTER the rounding, in the same kernel pass; default [`Activation::Identity`](./index.md#Activation).

**Returns:** the broadcast-shaped quotient at the promoted dtype.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the operand shapes are not broadcast-compatible. Also raises (`INVALID_ARGUMENT`) for a non-float `activation` operand dtype.

  ```cpp
  auto q = ClikaRT::ops::div(a, b);  // true division
  auto f = ClikaRT::ops::div(a, b, ClikaRT::ops::RoundingMode::Floor);
  ```

<div class="api-declared">

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

</div>

## div(Scalar, Tensor, RoundingMode, Activation) {#div-2}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`div`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Scalar`](../Scalar.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `other`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`RoundingMode`](./index.md#RoundingMode) `rounding_mode` `=` [`RoundingMode::None`](./index.md#RoundingMode),<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Activation`](./index.md#Activation) `activation` `=` [`Activation::Identity`](./index.md#Activation)<br />
)

</div>

Scalar-LHS `a / b`. `input` keeps its kind (see [`Scalar`](../Scalar.md)). The parameter set mirrors the tensor-first form: `rounding_mode` picks true/trunc/floor division, `activation` applies to the result.

<div class="api-declared">

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

</div>
