Skip to main content

ClikaRT::graph::CompiledFunction

class

Header: ClikaRT/graph/compile.h

The self-capturing callable ClikaRT::compile returns. Move-only.

In every state a call returns exactly what calling the wrapped function eagerly returns; a captured graph serves a call only when it ran cleanly on matching shapes; every other path serves the eager result.

Types

enum State

enum class State : std::uint8_t

Where the function is in its capture lifecycle. Fallback means the function serves eagerly and will not re-capture on its own; after a failed capture, a failed graph run, shape drift past the re-capture budget, or a take_graph(); reset() re-arms it.

EnumeratorDescription
Pendingno capture yet; the next healthy call captures
Compileda captured graph serves shape-matching calls
Fallbackserving eagerly until an explicit reset()

Declared in ClikaRT/graph/compile.h, line 153

Member functions

CompiledFunction(CompiledFunction)

CompiledFunction(CompiledFunction&&) noexcept

Move-only: transfers the compiled function.

Declared in ClikaRT/graph/compile.h, line 163

operator=(CompiledFunction)

CompiledFunction& operator=(CompiledFunction&&) noexcept

Move-assign: transfers the compiled function.

Declared in ClikaRT/graph/compile.h, line 165

CompiledFunction(CompiledFunction)

CompiledFunction(const CompiledFunction&) =delete

Declared in ClikaRT/graph/compile.h, line 166

operator=(CompiledFunction)

CompiledFunction& operator=(const CompiledFunction&) =delete

Declared in ClikaRT/graph/compile.h, line 167

~CompiledFunction()

~CompiledFunction()

Releases the compiled function.

Declared in ClikaRT/graph/compile.h, line 169

call_impl()

Result<std::vector<Tensor>> call_impl(const std::vector<Tensor>& inputs)

Call the function: positional inputs in, positional outputs out, the same contract as calling the wrapped function directly. Raises ClikaRT::Error exactly when the eager function would. A graph-served call returns exactly the function's own outputs; state outputs the capture surfaces ride the captured graph (take_graph), never the call.

Declared in ClikaRT/graph/compile.h, line 177

operator()()

std::vector<Tensor> operator()(const std::vector<Tensor>& inputs)

Declared in ClikaRT/graph/compile.h, line 178

state()

State state() const

The current capture state.

Declared in ClikaRT/graph/compile.h, line 183

recapture_count()

std::int64_t recapture_count() const

How many times drifted input shapes forced a re-capture.

Declared in ClikaRT/graph/compile.h, line 186

take_graph()

ModelGraph take_graph()

Take the captured ModelGraph out of the function, the road into a serving pipeline (runtime::from_graph), where a node needs the graph's I/O specs at creation. Consuming: afterwards the function serves eagerly (Fallback) until reset(). Available in Compiled only; in Pending or Fallback it raises a readable NOT_FOUND error; drive one healthy call through the function first.

Declared in ClikaRT/graph/compile.h, line 195

reset()

void reset()

Re-arm capture: back to Pending, dropping any captured graph and the re-capture count. The explicit companion of the no-staleness-detection contract; after changing state the function reads (a weight swap, a device move), reset() and the next call re-captures.

Declared in ClikaRT/graph/compile.h, line 201

Static data members

kMaxRecaptures

static std::int64_t kMaxRecaptures = 4

Re-captures a CompiledFunction performs before latching Fallback.

Declared in ClikaRT/graph/compile.h, line 160