---
title: "ClikaRT::ScalarOrTensor"
sidebar_label: "ScalarOrTensor"
description: "A ClikaRT-level value type (NOT op-layer machinery): one optional slot that carries a scalar (a bool, an integer or a double) OR a tensor. Every ctor is implicit on purpose."
---

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

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

**Header:** `ClikaRT/compute/ops.h`

A ClikaRT-level value type (NOT op-layer machinery): one optional slot that carries a scalar (a bool, an integer or a double) OR a tensor. Every ctor is implicit on purpose. Pass a bare `bool`, `double`, an integer, a [`Tensor`](./Tensor.md), or `std::nullopt` straight to a [`ScalarOrTensor`](./ScalarOrTensor.md) parameter; spelling the wrap at a call site (`ops::ScalarOrTensor(x)`) is redundant noise. [`ops::ScalarOrTensor`](./ops/ScalarOrTensor.md) remains a valid spelling via the alias below.

## Member functions

### ScalarOrTensor() {#ScalarOrTensor}

<div class="api-signature">

**`ScalarOrTensor`**() `=default`

</div>

Absent: the "not provided" state for optional scalar-or-tensor parameters (a kernel-launch bound, an optional clip limit). An absent value tells the op to derive its own default.

<div class="api-declared">

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

</div>

### ScalarOrTensor(nullopt\_t) {#ScalarOrTensor-2}

<div class="api-signature">

**`ScalarOrTensor`**(`std::nullopt_t`)

</div>

Absent, spelled `std::nullopt` at a call site (same meaning as the default ctor).

<div class="api-declared">

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

</div>

### ScalarOrTensor(bool) {#ScalarOrTensor-3}

<div class="api-signature">

**`ScalarOrTensor`**(`bool` `v`)

</div>

A boolean scalar operand; it keeps Bool kind across the boundary (a Bool tensor filled with `true` reads true), never widened to an int. Declared ahead of the integral template so a `bool` lands here exactly.

<div class="api-declared">

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

</div>

### ScalarOrTensor(double) {#ScalarOrTensor-4}

<div class="api-signature">

**`ScalarOrTensor`**(`double` `scalar`)

</div>

A double scalar operand.

<div class="api-declared">

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

</div>

### ScalarOrTensor(T) {#ScalarOrTensor-5}

<div class="api-signature">

`template <``typename T`, `typename std::enable_if<std::is_integral<T>::value, int>::type` `=` `0``>`<br />**`ScalarOrTensor`**(`T` `v`)

</div>

Integral values keep their integer-ness across the boundary: an integer-typed gateway slot (a split size, an index literal) rejects a float literal, so `{n * d, ...}` must not decay to double. Templated over the integral types so every width lands here exactly, never on the double ctor, and never ambiguously against it.

<div class="api-declared">

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

</div>

### ScalarOrTensor(optional\<int64\_t\>) {#ScalarOrTensor-6}

<div class="api-signature">

**`ScalarOrTensor`**(`std::optional<std::int64_t>` `v`)

</div>

`std::optional<int64_t>` maps nullopt → absent, a value → the int arm, so a caller holding an optional config int passes it directly.

<div class="api-declared">

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

</div>

### ScalarOrTensor(optional\<double\>) {#ScalarOrTensor-7}

<div class="api-signature">

**`ScalarOrTensor`**(`std::optional<double>` `v`)

</div>

`std::optional<double>` maps nullopt → absent, a value → the scalar arm (the double sibling of the optional-int ctor above).

<div class="api-declared">

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

</div>

### ScalarOrTensor(Tensor) {#ScalarOrTensor-8}

<div class="api-signature">

**`ScalarOrTensor`**([`Tensor`](./Tensor.md) `tensor`)

</div>

A full tensor operand; the slot then broadcasts like any tensor input.

<div class="api-declared">

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

</div>

### has\_value() {#has_value}

<div class="api-signature">

`bool` **`has_value`**() `const`

</div>

True when a value is present (absent tells the op to derive its own default).

<div class="api-declared">

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

</div>

### is\_tensor() {#is_tensor}

<div class="api-signature">

`bool` **`is_tensor`**() `const`

</div>

True when the slot carries a tensor.

<div class="api-declared">

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

</div>

### is\_bool() {#is_bool}

<div class="api-signature">

`bool` **`is_bool`**() `const`

</div>

True when the slot carries a bool (kept Bool, never widened to an int).

<div class="api-declared">

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

</div>

### is\_int() {#is_int}

<div class="api-signature">

`bool` **`is_int`**() `const`

</div>

True when the slot carries an integer (kept integral, never decayed to double).

<div class="api-declared">

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

</div>

### scalar() {#scalar}

<div class="api-signature">

`double` **`scalar`**() `const`

</div>

The double value; meaningful when present and neither tensor nor integer.

<div class="api-declared">

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

</div>

### int\_value() {#int_value}

<div class="api-signature">

`std::int64_t` **`int_value`**() `const`

</div>

The integer value; meaningful when [`is_int()`](./ScalarOrTensor.md#is_int).

<div class="api-declared">

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

</div>

### bool\_value() {#bool_value}

<div class="api-signature">

`bool` **`bool_value`**() `const`

</div>

The bool value; meaningful when [`is_bool()`](./ScalarOrTensor.md#is_bool).

<div class="api-declared">

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

</div>

### tensor() {#tensor}

<div class="api-signature">

`const` [`Tensor`](./Tensor.md)`&` **`tensor`**() `const`

</div>

The tensor operand; meaningful when [`is_tensor()`](./ScalarOrTensor.md#is_tensor).

<div class="api-declared">

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

</div>
