linear

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package linear provides a cached linear (matrix multiply) operator backed by the Apple Neural Engine.

exec := linear.New(rt)
defer exec.Close()

y, err := exec.Linear(x, w, batch, inDim, outDim)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor manages a cache of ANE kernels for linear operations.

func New

func New(rt *ane.Runtime) *Executor

New creates a new linear executor.

func (*Executor) Close

func (e *Executor) Close() error

Close releases all cached kernels.

func (*Executor) Linear

func (e *Executor) Linear(x, w []float32, batch, inDim, outDim int) ([]float32, error)

Linear computes y = x @ W^T using the ANE.

x has shape [batch, inDim] (row-major), w has shape [outDim, inDim] (row-major), and the result has shape [batch, outDim].

func (*Executor) Prepare

func (e *Executor) Prepare(w []float32, batch, inDim, outDim int) error

Prepare pre-compiles a kernel for the given weight matrix and shape.

func (*Executor) Stats

func (e *Executor) Stats() Stats

Stats returns cache statistics.

type Stats

type Stats struct {
	CachedKernels int
}

Stats reports cache statistics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL