CixP1.Graph (CixP1 v0.1.1)

Copy Markdown View Source

A compiled model graph loaded onto the NPU.

Load an offline-built graph binary (.cix, produced by the NOE Compiler or pulled from the CIX AI Model Hub) with load/2, then inspect its input and output tensors via the descriptor functions. Run inference through CixP1.Job or the CixP1.run/2 convenience.

Summary

Types

A tensor descriptor as reported by libnoe.

t()

Functions

Number of input tensors the graph expects.

Descriptor for input tensor index (0-based).

All input descriptors, in order.

Loads a compiled graph binary from path into context.

Number of output tensors the graph produces.

Descriptor for output tensor index (0-based).

All output descriptors, in order.

Types

descriptor()

@type descriptor() :: %{
  id: non_neg_integer(),
  size: non_neg_integer(),
  scale: float(),
  zero_point: integer(),
  data_type: atom() | non_neg_integer()
}

A tensor descriptor as reported by libnoe.

  • :id — tensor id within the graph
  • :size — buffer size in bytes
  • :scale / :zero_point — quantization parameters (real = (q - zero_point) * scale)
  • :data_type — element type atom (:u8, :s8, :s16, :s32, :f16, :f32, …) or the raw integer for types without an atom mapping

t()

@type t() :: %CixP1.Graph{context: CixP1.Context.t(), resource: reference()}

Functions

input_count(graph)

@spec input_count(t()) :: {:ok, non_neg_integer()} | {:error, String.t()}

Number of input tensors the graph expects.

input_descriptor(graph, index)

@spec input_descriptor(t(), non_neg_integer()) ::
  {:ok, descriptor()} | {:error, String.t()}

Descriptor for input tensor index (0-based).

input_descriptors(graph)

@spec input_descriptors(t()) :: {:ok, [descriptor()]} | {:error, String.t()}

All input descriptors, in order.

load(context, path)

@spec load(CixP1.Context.t(), Path.t()) :: {:ok, t()} | {:error, String.t()}

Loads a compiled graph binary from path into context.

output_count(graph)

@spec output_count(t()) :: {:ok, non_neg_integer()} | {:error, String.t()}

Number of output tensors the graph produces.

output_descriptor(graph, index)

@spec output_descriptor(t(), non_neg_integer()) ::
  {:ok, descriptor()} | {:error, String.t()}

Descriptor for output tensor index (0-based).

output_descriptors(graph)

@spec output_descriptors(t()) :: {:ok, [descriptor()]} | {:error, String.t()}

All output descriptors, in order.