linear

package
v0.2.0 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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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