---
title: "ClikaRT::graph::Value"
sidebar_label: "Value"
description: "A tensor on a graph edge: an operator's output on one port, a graph input, or a constant (a weight bound into the graph)."
---

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

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

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

A tensor on a graph edge: an operator's output on one port, a graph input, or a constant (a weight bound into the graph). One value per (producer, port): the same tensor consumed by two operators is one value, and every view of it compares equal and hashes alike (`std::hash<`[`Value`](./Value.md)`>`), whichever node listed it. The view finds its value again by that key after an edit; once no value has it, the view answers empty and [`check()`](./Value.md#check) says so.

## Member functions

### check() {#check}

<div class="api-signature">

`void` **`check`**() `const`

</div>

Nothing when the graph still holds this value; [`Status::InvalidArgument`](../../index.md#Status) naming the producer and port when it no longer does (the producer was removed or renamed, or reads of that port are gone) or when the graph itself no longer exists.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 111

</div>

### name() {#name}

<div class="api-signature">

`std::string` **`name`**() `const`

</div>

The name the graph declared for this tensor: a graph output's declared name, the same through every view of the value. Every other value is unnamed (empty): identify it by its producer and port, and read a graph input's name from its `Input` node.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 116

</div>

### spec() {#spec}

<div class="api-signature">

[`spec::TensorSpec`](../spec/TensorSpec.md) **`spec`**() `const`

</div>

The (name, dtype, dims) spec. A dim the graph left dynamic reads as [`spec::TensorSpec::kDynamicDim`](../spec/TensorSpec.md#kDynamicDim) and keeps the model's name for it, when there is one, in `dim_names`.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 120

</div>

### is\_constant() {#is_constant}

<div class="api-signature">

`bool` **`is_constant`**() `const`

</div>

A constant: a weight or another tensor bound into the graph, with bytes fixed for the graph's lifetime. [`constant()`](./Value.md#constant) reads them.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 123

</div>

### is\_state() {#is_state}

<div class="api-signature">

`bool` **`is_state`**() `const`

</div>

A live state buffer the graph seeds and rewrites in place between runs (a key/value cache plane): bound like a constant, but its bytes change.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 126

</div>

### is\_graph\_input() {#is_graph_input}

<div class="api-signature">

`bool` **`is_graph_input`**() `const`

</div>

A runtime input: the output of an `Input` node, bound by the caller at `run`.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 129

</div>

### is\_graph\_output() {#is_graph_output}

<div class="api-signature">

`bool` **`is_graph_output`**() `const`

</div>

A graph output: one of the tensors `run` returns.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 131

</div>

### producer() {#producer}

<div class="api-signature">

`std::optional<`[`Node`](./Node.md)`>` **`producer`**() `const`

</div>

The node that produces this value. Empty for a constant or a state buffer: no operator produces those.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 134

</div>

### producer\_port() {#producer_port}

<div class="api-signature">

`int` **`producer_port`**() `const`

</div>

The output port of [`producer()`](./Value.md#producer) this value leaves on (0 when there is no producer).

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 137

</div>

### constant() {#constant}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`constant`**() `const`

</div>

The constant's tensor: a shared handle to the bound bytes, no copy. Fails with [`Status::InvalidArgument`](../../index.md#Status) when the value is not a constant.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 141

</div>

### uses() {#uses}

<div class="api-signature">

`std::vector<`[`Edge`](./Edge.md)`>` **`uses`**() `const`

</div>

The edges carrying this value to its readers, one per read, in (consumer name, consumer input port) order; returning the value from the graph is no read. Edges join nodes, so the list of a constant or a state buffer is empty: [`consumers()`](./Value.md#consumers) and `Node::input(port)` reach its reads.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 146

</div>

### consumers() {#consumers}

<div class="api-signature">

`std::vector<`[`Node`](./Node.md)`>` **`consumers`**() `const`

</div>

The operators that read this value, each once, in the order of their reads; a constant's or a state buffer's readers too.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 149

</div>

## Friends

### operator== {#operator-eq}

<div class="api-signature">

`friend` `bool` **`operator==`**(`const Value&` `a`, `const Value&` `b`) `noexcept`

</div>

Two views of the same value (the same graph, producer and output port) compare equal.

<div class="api-declared">

Declared in `ClikaRT/graph/node.h`, line 153

</div>
