CixP1.Graph (CixP1 v0.1.2)

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.

Tensor name and logical shape, read from the .cix model file.

t()

Functions

Number of input tensors the graph expects.

Descriptor for input tensor index (0-based).

All input descriptors, in order.

Name and logical shape of input tensor index (0-based).

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.

Name and logical shape of output tensor index (0-based). See input_shape/2.

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

shape_info()

@type shape_info() :: %{name: binary(), shape: [integer()]}

Tensor name and logical shape, read from the .cix model file.

t()

@type t() :: %CixP1.Graph{
  context: CixP1.Context.t(),
  path: Path.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.

input_shape(graph, index)

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

Name and logical shape of input tensor index (0-based).

Descriptors carry only element type and flat byte size; the shape is read from the .cix model file on disk, so the file must still be present at the path the graph was loaded from.

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.

output_shape(graph, index)

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

Name and logical shape of output tensor index (0-based). See input_shape/2.