wasm

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Unlicense Imports: 12 Imported by: 0 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

Index

Constants

View Source
const (
	// MaxInputFloats bounds the size of a single inference input to avoid OOMs.
	MaxInputFloats = 1 << 20 // ~4 MiB of float32
	// MaxOutputFloats bounds the size of a single inference output.
	MaxOutputFloats = 1 << 20 // ~4 MiB of float32
)

Variables

View Source
var (
	ErrInvalidModule   = errors.New("wasm: invalid module")
	ErrMissingExport   = errors.New("wasm: missing required export")
	ErrMemoryBounds    = errors.New("wasm: memory bounds exceeded")
	ErrInferenceFailed = errors.New("wasm: inference failed")
	ErrModuleClosed    = errors.New("wasm: module closed")
	ErrInputTooLarge   = errors.New("wasm: input too large")
	ErrOutputTooLarge  = errors.New("wasm: output too large")
)

Functions

This section is empty.

Types

type Runner

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

Runner handles WASM model execution

func NewRunner

func NewRunner(ctx context.Context, modelPath string) (*Runner, error)

NewRunner creates a new WASM runner for the given model path

func (*Runner) Close

func (r *Runner) Close(ctx context.Context) error

func (*Runner) Inference

func (r *Runner) Inference(ctx context.Context, input []float32) ([]float32, error)

Inference executes the model's inference function using shared memory

func (*Runner) InferenceWithTokens

func (r *Runner) InferenceWithTokens(ctx context.Context, inputIds []int64, mask []int64) ([]float32, error)

InferenceWithTokens executes the model's inference function using tokenized int64 inputs

Jump to

Keyboard shortcuts

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