HexagonTpu.Runtime (hexagon_tpu v0.1.1)

Copy Markdown

A QNN backend runtime: the dlopen'd backend library plus its backend and device handles.

The HTP (NPU) is a shared SoC resource — use htp/0 to get a process-wide memoized runtime instead of creating one per caller. Explicit create/1 remains useful for the CPU backend or custom library paths (e.g. host-side testing).

close/1 waits for in-flight executes and returns {:error, :contexts_alive} while contexts created from this runtime are still open — close contexts first (or let the GC destructors handle teardown in dependency order).

Error shapes across the library: {:error, tag} for simple conditions (:runtime_closed, :graph_not_found, ...), {:error, {tag, detail}} for tagged details ({:dlopen_failed, msg}, {:unsupported_tensor_type, name}), and {:error, {:qnn, code, message}} for QNN backend errors.

Summary

Functions

Frees the QNN backend/device handles. Idempotent. Returns {:error, :contexts_alive} while contexts from this runtime are open.

Creates a QNN runtime.

Returns the shared HTP runtime, creating it on first use.

Backend library name, build id and device availability.

Types

t()

@type t() :: %HexagonTpu.Runtime{resource: reference()}

Functions

close(runtime)

Frees the QNN backend/device handles. Idempotent. Returns {:error, :contexts_alive} while contexts from this runtime are open.

create(opts \\ [])

Creates a QNN runtime.

Options:

  • :backend - :htp (default) or :cpu
  • :lib_path - override the backend library name/path
  • :system_lib_path - override the QnnSystem library (default "libQnnSystem.so")
  • :log_level - :none | :error | :warn | :info | :verbose | :debug (default :warn)

htp(opts \\ [])

Returns the shared HTP runtime, creating it on first use.

info(runtime)

Backend library name, build id and device availability.