pods

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoGPU = errors.New("gpu unavailable (build with -tags=gpu to enable)")

Single canonical error used across CPU/GPU builds.

Functions

func DeltaPack

func DeltaPack(in []uint64) []byte

func Names

func Names() []string

func Register

func Register(name string, fn Runner)

func Run

func Run(name string) error

func VarintDecode

func VarintDecode(b []byte) (u uint64, n int)

func VarintEncode

func VarintEncode(u uint64) []byte

Types

type AStarIn

type AStarIn struct {
	Map         GridMap
	Start, Goal [2]int
}

type AStarOut

type AStarOut struct{ Path [][2]int }

type AStarPod

type AStarPod struct{}

func (AStarPod) Name

func (AStarPod) Name() string

func (AStarPod) Run

func (AStarPod) Run(_ *ExecContext, in any) (any, error)

type AudioBuffer

type AudioBuffer struct {
	SampleRate int
	Channels   int
	Samples    [][]float32 // [ch][n]
}

type CullingIn

type CullingIn struct {
	Frustum Frustum
	Bounds  [][6]float32 // AABB: xmin,ymin,zmin,xmax,ymax,zmax
}

type CullingOut

type CullingOut struct{ Visible []bool }

type CullingPod

type CullingPod struct{}

func (CullingPod) Name

func (CullingPod) Name() string

func (CullingPod) Run

func (CullingPod) Run(_ *ExecContext, in any) (any, error)

type ExecContext

type ExecContext struct {
	Ctx      context.Context
	UseGPU   bool             // high-level knob; pods may override per-op
	Report   *detector.Report // detector output (limits, features, recs)
	GPU      GPUHooks         // nil unless -tags=gpu and initialized
	TempPool *Pool            // scratch buffers (optional)
	Now      time.Time
}

ExecContext carries execution choices and capabilities.

func NewContext

func NewContext(rep *detector.Report) *ExecContext

func (*ExecContext) WithGPU

func (ec *ExecContext) WithGPU(g GPUHooks) *ExecContext

type Frustum

type Frustum struct{ Planes [6][4]float32 } // ax+by+cz+d >= 0

type GEMMIn

type GEMMIn struct {
	M, N, K int
	A, B    []float32 // row-major A[M,K], B[K,N]
	Alpha   float32   // C = alpha*A*B + beta*C (beta=0 here for baseline)
}

type GEMMOut

type GEMMOut struct {
	C []float32 // row-major C[M,N]
}

type GEMMPod

type GEMMPod struct{}

func (GEMMPod) Name

func (GEMMPod) Name() string

func (GEMMPod) Run

func (GEMMPod) Run(x *ExecContext, in any) (any, error)

type GPUHooks

type GPUHooks interface {
	DispatchScanU32(in []uint32, inclusive bool) ([]uint32, error)
	DispatchReduceF32(in []float32, kind string) (float32, error) // kind: "sum"|"max"|"mean"
	DispatchSoftmaxF32(in []float32) ([]float32, error)
}

GPUHooks describes the optional GPU backend. Keep it slice-based so CPU fallback is easy.

var GPU GPUHooks = noopGPU{}

Default to a no-op GPU so everything builds/runs without tags.

type GridMap

type GridMap struct {
	W, H  int
	Solid func(x, y int) bool
	Cost  func(x, y int) float32 // optional; nil -> 1
}

type ImageFrame

type ImageFrame struct {
	W, H   int
	Pixels []float32 // RGB or RGBA planar/interleaved; keep it simple first
	Stride int
	Format string // "RGB", "RGBA", "YUV420", …
}

type LayerNormIn

type LayerNormIn struct {
	X   []float32
	Eps float32
}

type LayerNormOut

type LayerNormOut struct{ Y []float32 } // per-vector LN; extend with shape later

type LayerNormPod

type LayerNormPod struct{}

func (LayerNormPod) Name

func (LayerNormPod) Name() string

func (LayerNormPod) Run

func (LayerNormPod) Run(_ *ExecContext, in any) (any, error)

type Mesh

type Mesh struct {
	Positions []float32 // xyzxyz…
	Normals   []float32 // optional
	Indices   []uint32
}

type Pod

type Pod interface {
	Name() string
	Run(ctx *ExecContext, in any) (out any, err error)
}

Pod is a unit of work (scan, GEMM, culling, STFT, …).

type Pool

type Pool struct{}

Pool can hand out scratch slices to avoid GC churn (optional).

type RGBToYUVIn

type RGBToYUVIn struct {
	Frame ImageFrame // Format "RGB"
}

type RGBToYUVOut

type RGBToYUVOut struct {
	Y, U, V []float32 // planar 4:4:4 for simplicity
}

type RGBToYUVPod

type RGBToYUVPod struct{}

func (RGBToYUVPod) Name

func (RGBToYUVPod) Name() string

func (RGBToYUVPod) Run

func (RGBToYUVPod) Run(_ *ExecContext, in any) (any, error)

type ReduceIn

type ReduceIn struct {
	In   []float32
	Kind string // "sum"|"min"|"max"
}

type ReduceOut

type ReduceOut struct {
	Value float32
}

type ReducePod

type ReducePod struct{}

func (ReducePod) Name

func (ReducePod) Name() string

func (ReducePod) Run

func (ReducePod) Run(x *ExecContext, in any) (any, error)

type Runner

type Runner func() error

Runner is a simple demo/algorithm entry point.

type STFTIn

type STFTIn struct {
	Audio   AudioBuffer
	WinSize int
	Hop     int
	Window  string // "hann" (default), …
}

type STFTOut

type STFTOut struct {
	Spectrogram [][]complex64 // [frame][bin]
}

type STFTPod

type STFTPod struct{}

func (STFTPod) Name

func (STFTPod) Name() string

func (STFTPod) Run

func (STFTPod) Run(_ *ExecContext, in any) (any, error)

type ScanIn

type ScanIn struct {
	In        []uint32
	Inclusive bool
}

type ScanOut

type ScanOut struct {
	Out []uint32
}

type ScanPod

type ScanPod struct{}

func (ScanPod) Name

func (ScanPod) Name() string

func (ScanPod) Run

func (ScanPod) Run(x *ExecContext, in any) (any, error)

type SoftmaxIn

type SoftmaxIn struct{ Logits []float32 }

type SoftmaxOut

type SoftmaxOut struct{ Probs []float32 }

type SoftmaxPod

type SoftmaxPod struct{}

func (SoftmaxPod) Name

func (SoftmaxPod) Name() string

func (SoftmaxPod) Run

func (SoftmaxPod) Run(x *ExecContext, in any) (any, error)

type Tensor

type Tensor[T ~float32 | ~float64] struct {
	Data    []T
	Shape   []int // row-major
	Strides []int
}

func NewTensor

func NewTensor[T ~float32 | ~float64](shape ...int) Tensor[T]

Jump to

Keyboard shortcuts

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