---
title: "ClikaRT::spec::Dim"
sidebar_label: "Dim"
description: "A dynamic dimension as a first-class object: declare it once, use it everywhere it appears, and every use refers to the SAME size. Two ways a Dim ties dims together: By name."
---

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

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

**Header:** `ClikaRT/graph/input_specs.h`

A dynamic dimension as a first-class object: declare it once, use it everywhere it appears, and every use refers to the SAME size.

Two ways a [`Dim`](./Dim.md) ties dims together:

- **By name.** Models carry named dynamic dims ([`spec::TensorSpec::dim_names`](./TensorSpec.md#dim_names); ONNX calls them `dim_param`, e.g. "batch\_size" on every input): the same name means the same size wherever it appears. [`Dim`](./Dim.md)`("batch_size")` names that dimension.
- **By identity.** A default-constructed [`Dim()`](./Dim.md#Dim) is anonymous but carries identity; every copy of it refers to the same dimension, so passing one [`Dim`](./Dim.md) object into several `add_input` shapes ties those dims; the model assigns it a systematic name ("dim\_0", "dim\_1", …).

A [`Dim`](./Dim.md) may also carry a value: a single pin, or a min/opt/max range (the [`opt`](./Dim.md#opt) value is what a compiled graph is specialized to; min/max are validated). Valueless (declaration-only) is [`min`](./Dim.md#min)` == `[`opt`](./Dim.md#opt)` == `[`max`](./Dim.md#max)` == `[`kUnset`](./Dim.md#kUnset).

```text
Dim batch("batch_size");                       // named, unpinned
specs.bind(Dim("batch_size", 1));              // pin it at compile
specs.bind(Dim("sequence_length", 1, 128, 512));  // a range
```

## Member functions

### Dim() {#Dim}

<div class="api-signature">

**`Dim`**()

</div>

Anonymous with identity: copies of this object denote ONE dimension.

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 53

</div>

### Dim(string\_view) {#Dim-2}

<div class="api-signature">

`explicit` **`Dim`**(`std::string_view` `dim_name`)

</div>

A named dynamic dim, unpinned: a declaration to bind or pin later.

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 55

</div>

### Dim(string\_view, int64\_t) {#Dim-3}

<div class="api-signature">

**`Dim`**(`std::string_view` `dim_name`, `std::int64_t` `value`)

</div>

A named dim pinned to a single `value` (min == opt == max).

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 57

</div>

### Dim(string\_view, int64\_t, int64\_t, int64\_t) {#Dim-4}

<div class="api-signature">

**`Dim`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::string_view` `dim_name`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::int64_t` `min_value`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::int64_t` `opt_value`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::int64_t` `max_value`<br />
)

</div>

A named dim carrying a `min_value` / `opt_value` / `max_value` range.

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 60

</div>

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

<div class="api-signature">

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

</div>

True when the dim carries a value (its [`opt`](./Dim.md#opt) bound is set).

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 65

</div>

### pinned(int64\_t) {#pinned}

<div class="api-signature">

[`Dim`](./Dim.md) **`pinned`**(`std::int64_t` `value`) `const`

</div>

A copy of this dimension carrying a pinned value / range, the binding form of a declared [`Dim`](./Dim.md), so one object serves declaration AND compile-time pinning: `specs.bind(batch.pinned(2))`.

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 70

</div>

### pinned(int64\_t, int64\_t, int64\_t) {#pinned-2}

<div class="api-signature">

[`Dim`](./Dim.md) **`pinned`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::int64_t` `min_value`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::int64_t` `opt_value`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::int64_t` `max_value`<br />
) `const`

</div>

The range form of [`pinned`](./Dim.md#pinned): a copy carrying `min_value` / `opt_value` / `max_value`.

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 76

</div>

### token() {#token}

<div class="api-signature">

`const void*` **`token`**() `const noexcept`

</div>

The identity token of an anonymous [`Dim`](./Dim.md) (null for a named one): how a model recognizes the same anonymous dimension across uses.

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 86

</div>

## Data members

### name {#name}

<div class="api-signature">

`std::string` **`name`**

</div>

the dynamic dim's name (empty = anonymous with identity).

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 47

</div>

### min {#min}

<div class="api-signature">

`std::int64_t` **`min`** `=` [`kUnset`](./Dim.md#kUnset)

</div>

smallest extent ([`kUnset`](./Dim.md#kUnset) = unset).

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 48

</div>

### opt {#opt}

<div class="api-signature">

`std::int64_t` **`opt`** `=` [`kUnset`](./Dim.md#kUnset)

</div>

the extent a compiled graph specializes to.

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 49

</div>

### max {#max}

<div class="api-signature">

`std::int64_t` **`max`** `=` [`kUnset`](./Dim.md#kUnset)

</div>

largest extent ([`kUnset`](./Dim.md#kUnset) = unset).

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 50

</div>

## Static data members

### kUnset {#kUnset}

<div class="api-signature">

`static` `std::int64_t` **`kUnset`** `= -1`

</div>

sentinel: this bound is not set.

<div class="api-declared">

Declared in `ClikaRT/graph/input_specs.h`, line 45

</div>
