XI · Hexagon NPU (welvet.qnn) / CHAPTER 74
QNN: opt-in Hexagon HTP (welvet.qnn)
github.com/openfluke/welvet/nativeqnn✅ windows/arm64 + cgo
Why it exists
Qualcomm Hexagon HTP is a sibling engine (welvet.qnn 1.0.0), not a silent fallback inside Go. Opt-in BackendQNN + explicit SyncToQNN keep CPU/SIMD/WebGPU as defaults. Caps reject unsupported layer/dtype mounts.
What it is
nativeqnn.Available(), Version(), SupportedLayers(), Dense SyncToQNN → PrepareQNN → Forward with BackendQNN. FormatNone host weights; HTP may run f16/i8/… inside the DLL.
Needs Windows ARM64, cgo, and shipped libwelvet_qnn.dll (plus Qualcomm
QAIRT runtime on PATH). Other OS/arch → Available()==false and examples print SKIP.
Layer tour: §80. Large-shape matrix + % wins: §81. NativeCPU twin: §76.
Go host (FormatNone f32) SyncToQNN / mirror welvet.qnn DLL Dense / Softmax / … ──► caps-check + Capture ──► HTP graphExecute BackendQNN Forward ◄── unpack y to Tensor ◄── dtype inside NPU
Go example
Run:
cd welvet/examples/79-qnn && source ../env.sh && go run .package main
import (
"fmt"
"github.com/openfluke/welvet/core"
"github.com/openfluke/welvet/layers/dense"
"github.com/openfluke/welvet/nativeqnn"
"github.com/openfluke/welvet/quant"
)
func main() {
fmt.Println("version", nativeqnn.Version())
fmt.Println("available", nativeqnn.Available())
fmt.Println("default", core.DefaultBackend())
if !nativeqnn.Available() {
fmt.Println("SKIP: need windows/arm64 + libwelvet_qnn (+ QAIRT)")
return
}
fmt.Println("layers", nativeqnn.SupportedLayers())
init := make([]float32, 4*4)
for i := range init {
init[i] = float32(i+1) * 0.05
}
l, err := dense.NewConfigured(4, 4, core.ActivationLinear, core.DTypeFloat32, quant.FormatNone, init)
must(err)
must(l.SyncToQNN())
must(l.PrepareQNN(2))
l.Exec.Backend = core.BackendQNN
x := core.NewTensor[float32](2, 4)
for i := range x.Data {
x.Data[i] = float32(i+1) * 0.1
}
_, post, err := dense.Forward(l, x)
must(err)
fmt.Println("fwd", len(post.Data), "backend", l.Exec.Backend)
fmt.Println("qnn done")
}
func must(err error) {
if err != nil {
panic(err)
}
}
Output
version
available false
default cpu-tiled
SKIP: need windows/arm64 + libwelvet_qnn (+ QAIRT)
Validate (harness)
cd welvet/examples/79-qnn && source ../env.sh && go run .