//clika-runtime/io.clika.runtime/ModelGraph
ModelGraph
[common]
class ModelGraph
A compiled model: its I/O contract, its placement, and its runs. A graph runs once it is finalized (finalizeGraph: placed on its device, the weights packed, the execution order planned); a run before that fails with FAILED_PRECONDITION. to moves it to a device or a stream, before finalizing (recording where finalizing places it) or after (moving the finalized graph). AutoCloseable: close releases the graph.
Properties
| Name | Summary |
|---|---|
| device | [common] val device: Device The device the graph serves on. |
| inputNames | [common] val inputNames: List<String> The runtime input names in declaration order, the order the positional run binds. |
| isEmpty | [common] val isEmpty: Boolean True for a graph that holds none (moved from, or consumed). |
| isFinalized | [common] val isFinalized: Boolean True once finalizeGraph ran. |
| outputNames | [common] val outputNames: List<String> The output names in declaration order, the order every run answers. |
Functions
| Name | Summary |
|---|---|
| close | [common] open fun close() |
| finalizeGraph | [common] fun finalizeGraph() Finalize the graph for serving: place it on its device, pack the weights into their kernel layouts, absorb the constants and plan the execution order. A second call changes nothing. (The name carries the word Graph because finalize alone is the JVM's own method.) |
| inputs | [common] fun inputs(): List<TensorSpec> The input slots as specs, in inputNames order (a dim the graph left dynamic reads as TensorSpec.DYNAMIC_DIM). |
| optimize | [common] fun optimize(options: OptimizeOptions = OptimizeOptions()): OptimizeReport Run the graph optimizer with the graph's own transform list, iterated until an iteration changes nothing or the cap stops it; a transform that fails is undone and skipped, and the run goes on. Refuses FAILED_PRECONDITION on a finalized graph. |
| outputs | [common] fun outputs(): List<TensorSpec> The output slots as specs, in outputNames order. |
| run | [common] fun run(inputs: List<Tensor>): List<Tensor> Run with positional inputs (one per inputNames entry, that order); the outputs in outputNames order, fresh tensors the caller owns. [common] fun run(inputs: Map<String, Tensor>): List<Tensor> Run with named inputs (every runtime input present, every name an input); the outputs in outputNames order. [common] fun run(inputs: List<Tensor>, boundOutputs: List<Tensor>): List<Tensor> Run with positional inputs, landing the results in boundOutputs, one caller-preallocated buffer per outputNames entry shaped and typed to accept its result; the answered tensors alias the bound buffers. [common] fun run(inputs: Map<String, Tensor>, boundOutputs: Map<String, Tensor>): List<Tensor> Run with named inputs and named output bindings (every binding name an output; an unbound output comes back fresh). |
| to | [common] fun to(where: Placement) Move the graph to a device or a stream ( to(stream) once, then every run computes on it). |