# `TFLiteElixir.SignatureRunner`
[🔗](https://github.com/cocoa-xu/tflite_elixir/blob/main/lib/tflite_elixir/signature_runner.ex#L1)

A runner for one of a model's signatures.

A signature names a subgraph together with its inputs and outputs, so tensors are
addressed by name instead of by index and the order of a model's outputs no longer
has to be worked out. Obtain one with `TFLiteElixir.Interpreter.get_signature_runner/2`.

A runner belongs to the interpreter it came from and keeps that interpreter alive, so
it stays usable even if nothing else refers to the interpreter any more. Like the
interpreter it is not safe to use from more than one process at a time.

# `nif_error`

```elixir
@type nif_error() :: {:error, String.t()}
```

# `allocate_tensors`

```elixir
@spec allocate_tensors(reference()) :: :ok | nif_error()
```

Allocate the tensors of the signature's subgraph.

# `cancel`

```elixir
@spec cancel(reference()) :: :ok | nif_error()
```

Cancel an in-flight invocation.

# `input_names`

```elixir
@spec input_names(reference()) :: {:ok, [String.t()]} | nif_error()
```

The names of the signature's inputs.

# `input_names!`

Raising version of `input_names/1`.

# `input_size`

```elixir
@spec input_size(reference()) :: {:ok, non_neg_integer()} | nif_error()
```

How many inputs the signature has.

# `input_size!`

Raising version of `input_size/1`.

# `input_tensor`

```elixir
@spec input_tensor(reference(), String.t(), binary()) :: :ok | nif_error()
```

Write data into the named input.

`allocate_tensors/1` has to have been called first.

# `invoke`

```elixir
@spec invoke(reference()) :: :ok | nif_error()
```

Run the signature.

# `output_names`

```elixir
@spec output_names(reference()) :: {:ok, [String.t()]} | nif_error()
```

The names of the signature's outputs.

# `output_names!`

Raising version of `output_names/1`.

# `output_size`

```elixir
@spec output_size(reference()) :: {:ok, non_neg_integer()} | nif_error()
```

How many outputs the signature has.

# `output_size!`

Raising version of `output_size/1`.

# `output_tensor`

```elixir
@spec output_tensor(reference(), String.t()) :: {:ok, binary()} | nif_error()
```

Read the named output.

# `output_tensor!`

Raising version of `output_tensor/2`.

# `predict`

```elixir
@spec predict(reference(), %{required(String.t()) =&gt; binary()}) ::
  {:ok, %{required(String.t()) =&gt; binary()}} | nif_error()
```

Feed the signature its inputs, run it and read every output back.

Inputs and outputs are maps keyed by the names the signature declares, which is what
makes a signature worth using: neither side depends on the order the model happens to
list its tensors in.

# `predict!`

Raising version of `predict/2`.

# `resize_input_tensor`

```elixir
@spec resize_input_tensor(reference(), String.t(), [integer()] | tuple()) ::
  :ok | nif_error()
```

Change the dimensions of the named input.

`allocate_tensors/1` has to be called again afterwards.

`dims` is a list, or the tuple `TFLiteElixir.TFLiteTensor.shape/1` returns.

# `resize_input_tensor_strict`

```elixir
@spec resize_input_tensor_strict(reference(), String.t(), [integer()] | tuple()) ::
  :ok | nif_error()
```

Change the dimensions of the named input, keeping the rank fixed.

Only dimensions the model left unknown can be changed.

`dims` is a list, or the tuple `TFLiteElixir.TFLiteTensor.shape/1` returns.

# `signature_key`

```elixir
@spec signature_key(reference()) :: {:ok, String.t()} | nif_error()
```

The key this runner was obtained with.

# `signature_key!`

Raising version of `signature_key/1`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
