Documentation
¶
Overview ¶
Package core provides core neural network layer implementations.
Package core provides core layer implementations for the Zerfoo ML framework.
Package core provides core layer implementations for the Zerfoo ML framework.
Package core provides core layer implementations for the Zerfoo ML framework.
Stability: stable
Package core provides core layer implementations for the Zerfoo ML framework.
Package core provides core layer implementations for the Zerfoo ML framework.
Package core provides core neural network layer implementations.
Package core provides core neural network layer implementations.
Package core provides core layer implementations for the Zerfoo ML framework.
Package core provides the Shape layer for the Zerfoo ML framework.
Package core provides core neural network layer implementations.
Package core provides core layer implementations for the Zerfoo ML framework.
Package core provides core layer implementations for the Zerfoo ML framework.
Index ¶
- func BuildAdd[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], name string, ...) (graph.Node[T], error)
- func BuildCast[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildConcat[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildConstantOfShape[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildConv2d[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildCos[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildDiv[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildEqual[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildExpand[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildFFN[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], name string, ...) (graph.Node[T], error)
- func BuildFiLM[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], name string, ...) (graph.Node[T], error)
- func BuildGemm[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildGlobalAveragePool[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildGreater[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildLessOrEqual[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildMatMul[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildMax[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildMixtureOfExperts[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildMoEGate[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildMod[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildMul[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildNeg[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildOr[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildPad[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildPow[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildRange[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildReduceMean[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildReshape[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildResize[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildRotaryEmbedding[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], name string, ...) (graph.Node[T], error)
- func BuildScatterND[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildShape[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildSin[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildSlice[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildSpectralFingerprint[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildSqrt[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildSqueeze[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildSub[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildTile[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildTopK[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildTrilu[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildUnsqueeze[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- func BuildWhere[T tensor.Numeric](engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, ...) (graph.Node[T], error)
- type Add
- func (a *Add[T]) Attributes() map[string]any
- func (a *Add[T]) Backward(_ context.Context, mode types.BackwardMode, dOut *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (a *Add[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (a *Add[T]) OpType() string
- func (a *Add[T]) OutputShape() []int
- func (a *Add[T]) Parameters() []*graph.Parameter[T]
- type Bias
- func NewBias[T tensor.Numeric](name string, engine compute.Engine[T], ops numeric.Arithmetic[T], size int, ...) (*Bias[T], error)
- func NewBiasFromParam[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], ...) *Bias[T]
- func NewBiasWithFactories[T tensor.Numeric](name string, engine compute.Engine[T], ops numeric.Arithmetic[T], size int, ...) (*Bias[T], error)
- func (b *Bias[T]) Attributes() map[string]interface{}
- func (b *Bias[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (b *Bias[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (b *Bias[T]) OpType() string
- func (b *Bias[T]) OutputShape() []int
- func (b *Bias[T]) Parameters() []*graph.Parameter[T]
- func (b *Bias[T]) SetName(name string)
- type BiasOption
- type BiasOptions
- type Cast
- func (c *Cast[T]) Attributes() map[string]interface{}
- func (c *Cast[T]) Backward(_ context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (c *Cast[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (c *Cast[T]) OpType() string
- func (c *Cast[T]) OutputShape() []int
- func (c *Cast[T]) Parameters() []*graph.Parameter[T]
- type Concat
- func (c *Concat[T]) Attributes() map[string]interface{}
- func (c *Concat[T]) Backward(_ context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (c *Concat[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (c *Concat[T]) OpType() string
- func (c *Concat[T]) OutputShape() []int
- func (c *Concat[T]) Parameters() []*graph.Parameter[T]
- type Constant
- func (c *Constant[T]) Attributes() map[string]interface{}
- func (c *Constant[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (c *Constant[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (c *Constant[T]) GetValue() *tensor.TensorNumeric[T]
- func (c *Constant[T]) IsMatrix() bool
- func (c *Constant[T]) IsScalar() bool
- func (c *Constant[T]) IsVector() bool
- func (c *Constant[T]) Name() string
- func (c *Constant[T]) NumElements() int
- func (c *Constant[T]) OpType() string
- func (c *Constant[T]) OutputShape() []int
- func (c *Constant[T]) Parameters() []*graph.Parameter[T]
- func (c *Constant[T]) SetName(name string)
- func (c *Constant[T]) String() string
- type ConstantOfShape
- func (c *ConstantOfShape[T]) Attributes() map[string]any
- func (c *ConstantOfShape[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (c *ConstantOfShape[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (c *ConstantOfShape[T]) OpType() string
- func (c *ConstantOfShape[T]) OutputShape() []int
- func (c *ConstantOfShape[T]) Parameters() []*graph.Parameter[T]
- type Conv1D
- func (c *Conv1D[T]) Attributes() map[string]interface{}
- func (c *Conv1D[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (c *Conv1D[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (c *Conv1D[T]) OpType() string
- func (c *Conv1D[T]) OutputShape() []int
- func (c *Conv1D[T]) Parameters() []*graph.Parameter[T]
- type Conv1DOption
- type Conv2d
- func (c *Conv2d[T]) Attributes() map[string]interface{}
- func (c *Conv2d[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (c *Conv2d[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (c *Conv2d[T]) OpType() string
- func (c *Conv2d[T]) OutputShape() []int
- func (c *Conv2d[T]) Parameters() []*graph.Parameter[T]
- type Cos
- func (c *Cos[T]) Attributes() map[string]any
- func (c *Cos[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (c *Cos[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (c *Cos[T]) OpType() string
- func (c *Cos[T]) OutputShape() []int
- func (c *Cos[T]) Parameters() []*graph.Parameter[T]
- type Dense
- func (d *Dense[T]) Attributes() map[string]interface{}
- func (d *Dense[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (d *Dense[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (d *Dense[T]) Name() string
- func (d *Dense[T]) OpType() string
- func (d *Dense[T]) OutputShape() []int
- func (d *Dense[T]) Parameters() []*graph.Parameter[T]
- func (d *Dense[T]) SetName(name string)
- type DenseOpt
- type Div
- func (d *Div[T]) Attributes() map[string]any
- func (d *Div[T]) Backward(ctx context.Context, _ types.BackwardMode, dOut *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (d *Div[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (d *Div[T]) OpType() string
- func (d *Div[T]) OutputShape() []int
- func (d *Div[T]) Parameters() []*graph.Parameter[T]
- type Equal
- func (e *Equal[T]) Attributes() map[string]any
- func (e *Equal[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (e *Equal[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (e *Equal[T]) OpType() string
- func (e *Equal[T]) OutputShape() []int
- func (e *Equal[T]) Parameters() []*graph.Parameter[T]
- type Expand
- func (e *Expand[T]) Attributes() map[string]any
- func (e *Expand[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (e *Expand[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (e *Expand[T]) OpType() string
- func (e *Expand[T]) OutputShape() []int
- func (e *Expand[T]) Parameters() []*graph.Parameter[T]
- type FFN
- func (f *FFN[T]) Attributes() map[string]interface{}
- func (f *FFN[T]) Backward(ctx context.Context, mode types.BackwardMode, dOut *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (f *FFN[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (f *FFN[T]) MergedGateUpParameter() *graph.Parameter[T]
- func (f *FFN[T]) OpType() string
- func (f *FFN[T]) OutputShape() []int
- func (f *FFN[T]) Parameters() []*graph.Parameter[T]
- func (f *FFN[T]) SetMergedGateUp(weight *tensor.TensorNumeric[T], gateDim, upDim int)
- type FFNConfig
- type FFNOpt
- type FiLM
- func (f *FiLM[T]) Attributes() map[string]interface{}
- func (f *FiLM[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (f *FiLM[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (f *FiLM[T]) OpType() string
- func (f *FiLM[T]) OutputShape() []int
- func (f *FiLM[T]) Parameters() []*graph.Parameter[T]
- type Gemm
- func (g *Gemm[T]) Attributes() map[string]any
- func (g *Gemm[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (g *Gemm[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (g *Gemm[T]) OpType() string
- func (g *Gemm[T]) OutputShape() []int
- func (g *Gemm[T]) Parameters() []*graph.Parameter[T]
- type GlobalAveragePool
- func (g *GlobalAveragePool[T]) Attributes() map[string]interface{}
- func (g *GlobalAveragePool[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (g *GlobalAveragePool[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (g *GlobalAveragePool[T]) OpType() string
- func (g *GlobalAveragePool[T]) OutputShape() []int
- func (g *GlobalAveragePool[T]) Parameters() []*graph.Parameter[T]
- type Greater
- func (g *Greater[T]) Attributes() map[string]any
- func (g *Greater[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (g *Greater[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (g *Greater[T]) OpType() string
- func (g *Greater[T]) OutputShape() []int
- func (g *Greater[T]) Parameters() []*graph.Parameter[T]
- type LMHead
- func (h *LMHead[T]) Backward(ctx context.Context, mode types.BackwardMode, dOut *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (h *LMHead[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (h *LMHead[T]) OutputShape() []int
- func (h *LMHead[T]) Parameters() []*graph.Parameter[T]
- func (h *LMHead[T]) SetWeights(weights *tensor.TensorNumeric[T])
- type LessOrEqual
- func (l *LessOrEqual[T]) Attributes() map[string]any
- func (l *LessOrEqual[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (l *LessOrEqual[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (l *LessOrEqual[T]) OpType() string
- func (l *LessOrEqual[T]) OutputShape() []int
- func (l *LessOrEqual[T]) Parameters() []*graph.Parameter[T]
- type Linear
- func (l *Linear[T]) Attributes() map[string]interface{}
- func (l *Linear[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (l *Linear[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (l *Linear[T]) Name() string
- func (l *Linear[T]) OpType() string
- func (l *Linear[T]) OutputShape() []int
- func (l *Linear[T]) Parameters() []*graph.Parameter[T]
- func (l *Linear[T]) SetName(name string)
- type MatMul
- func (m *MatMul[T]) Attributes() map[string]interface{}
- func (m *MatMul[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (m *MatMul[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (m *MatMul[T]) OpType() string
- func (m *MatMul[T]) OutputShape() []int
- func (m *MatMul[T]) Parameters() []*graph.Parameter[T]
- type MatMulNBits
- func (m *MatMulNBits[T]) Attributes() map[string]interface{}
- func (m *MatMulNBits[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (m *MatMulNBits[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (m *MatMulNBits[T]) GetDequantizedWeights() (*tensor.TensorNumeric[T], error)
- func (m *MatMulNBits[T]) InvalidateCache()
- func (m *MatMulNBits[T]) OpType() string
- func (m *MatMulNBits[T]) OutputShape() []int
- func (m *MatMulNBits[T]) Parameters() []*graph.Parameter[T]
- func (m *MatMulNBits[T]) QuantizationInfo() map[string]interface{}
- func (m *MatMulNBits[T]) String() string
- type Max
- func (m *Max[T]) Attributes() map[string]any
- func (m *Max[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (m *Max[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (m *Max[T]) OpType() string
- func (m *Max[T]) OutputShape() []int
- func (m *Max[T]) Parameters() []*graph.Parameter[T]
- type MixtureOfExperts
- func (m *MixtureOfExperts[T]) Attributes() map[string]any
- func (m *MixtureOfExperts[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (m *MixtureOfExperts[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (m *MixtureOfExperts[T]) OpType() string
- func (m *MixtureOfExperts[T]) OutputShape() []int
- func (m *MixtureOfExperts[T]) Parameters() []*graph.Parameter[T]
- type MoEGate
- func (g *MoEGate[T]) Attributes() map[string]interface{}
- func (g *MoEGate[T]) Backward(_ context.Context, _ types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (g *MoEGate[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (g *MoEGate[T]) OpType() string
- func (g *MoEGate[T]) OutputShape() []int
- func (g *MoEGate[T]) Parameters() []*graph.Parameter[T]
- type Mod
- func (m *Mod[T]) Attributes() map[string]any
- func (m *Mod[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (m *Mod[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (m *Mod[T]) OpType() string
- func (m *Mod[T]) OutputShape() []int
- func (m *Mod[T]) Parameters() []*graph.Parameter[T]
- type Mul
- func (m *Mul[T]) Attributes() map[string]interface{}
- func (m *Mul[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (m *Mul[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (m *Mul[T]) OpType() string
- func (m *Mul[T]) OutputShape() []int
- func (m *Mul[T]) Parameters() []*graph.Parameter[T]
- type Neg
- func (n *Neg[T]) Attributes() map[string]any
- func (n *Neg[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (n *Neg[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (n *Neg[T]) OpType() string
- func (n *Neg[T]) OutputShape() []int
- func (n *Neg[T]) Parameters() []*graph.Parameter[T]
- type Or
- func (o *Or[T]) Attributes() map[string]any
- func (o *Or[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (o *Or[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (o *Or[T]) OpType() string
- func (o *Or[T]) OutputShape() []int
- func (o *Or[T]) Parameters() []*graph.Parameter[T]
- type Pad
- func (p *Pad[T]) Attributes() map[string]interface{}
- func (p *Pad[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (p *Pad[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (p *Pad[T]) OpType() string
- func (p *Pad[T]) OutputShape() []int
- func (p *Pad[T]) Parameters() []*graph.Parameter[T]
- type PolynomialExpansion
- func (p *PolynomialExpansion[T]) Attributes() map[string]interface{}
- func (p *PolynomialExpansion[T]) Backward(_ context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (p *PolynomialExpansion[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (p *PolynomialExpansion[T]) GetDegree() int
- func (p *PolynomialExpansion[T]) GetInputSize() int
- func (p *PolynomialExpansion[T]) GetOutputSize() int
- func (p *PolynomialExpansion[T]) GetTermIndices() [][]int
- func (p *PolynomialExpansion[T]) HasBias() bool
- func (p *PolynomialExpansion[T]) OpType() string
- func (p *PolynomialExpansion[T]) OutputShape() []int
- func (p *PolynomialExpansion[T]) Parameters() []*graph.Parameter[T]
- func (p *PolynomialExpansion[T]) SetName(_ string)
- type PolynomialExpansionOption
- type PolynomialExpansionOptions
- type PoolMode
- type Pow
- func (p *Pow[T]) Attributes() map[string]any
- func (p *Pow[T]) Backward(ctx context.Context, _ types.BackwardMode, dOut *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (p *Pow[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (p *Pow[T]) OpType() string
- func (p *Pow[T]) OutputShape() []int
- func (p *Pow[T]) Parameters() []*graph.Parameter[T]
- type Range
- func (r *Range[T]) Attributes() map[string]any
- func (r *Range[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (r *Range[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (r *Range[T]) OpType() string
- func (r *Range[T]) OutputShape() []int
- func (r *Range[T]) Parameters() []*graph.Parameter[T]
- type ReduceMean
- func (r *ReduceMean[T]) Attributes() map[string]any
- func (r *ReduceMean[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (r *ReduceMean[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (r *ReduceMean[T]) OpType() string
- func (r *ReduceMean[T]) OutputShape() []int
- func (r *ReduceMean[T]) Parameters() []*graph.Parameter[T]
- type Reshape
- func (r *Reshape[T]) Attributes() map[string]interface{}
- func (r *Reshape[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (r *Reshape[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (r *Reshape[T]) OpType() string
- func (r *Reshape[T]) OutputShape() []int
- func (r *Reshape[T]) Parameters() []*graph.Parameter[T]
- type Resize
- func (r *Resize[T]) Attributes() map[string]interface{}
- func (r *Resize[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (r *Resize[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (r *Resize[T]) OpType() string
- func (r *Resize[T]) OutputShape() []int
- func (r *Resize[T]) Parameters() []*graph.Parameter[T]
- type RotaryEmbedding
- func (r *RotaryEmbedding[T]) Attributes() map[string]interface{}
- func (r *RotaryEmbedding[T]) Backward(_ context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (r *RotaryEmbedding[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (r *RotaryEmbedding[T]) Name() string
- func (r *RotaryEmbedding[T]) OpType() string
- func (r *RotaryEmbedding[T]) OutputShape() []int
- func (r *RotaryEmbedding[T]) Parameters() []*graph.Parameter[T]
- func (r *RotaryEmbedding[T]) SetName(name string)
- type ScatterND
- func (s *ScatterND[T]) Attributes() map[string]any
- func (s *ScatterND[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (s *ScatterND[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (s *ScatterND[T]) OpType() string
- func (s *ScatterND[T]) OutputShape() []int
- func (s *ScatterND[T]) Parameters() []*graph.Parameter[T]
- type SeqClassification
- func (s *SeqClassification[T]) Attributes() map[string]interface{}
- func (s *SeqClassification[T]) Backward(ctx context.Context, mode types.BackwardMode, dOut *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (s *SeqClassification[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (s *SeqClassification[T]) OpType() string
- func (s *SeqClassification[T]) OutputShape() []int
- func (s *SeqClassification[T]) Parameters() []*graph.Parameter[T]
- func (s *SeqClassification[T]) SetTraining(training bool)
- type SeqClassificationOpt
- type Shape
- func (s *Shape[T]) Attributes() map[string]interface{}
- func (s *Shape[T]) Backward(_ context.Context, mode types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (s *Shape[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (s *Shape[T]) OpType() string
- func (s *Shape[T]) OutputShape() []int
- func (s *Shape[T]) Parameters() []*graph.Parameter[T]
- type Sin
- func (s *Sin[T]) Attributes() map[string]any
- func (s *Sin[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (s *Sin[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (s *Sin[T]) OpType() string
- func (s *Sin[T]) OutputShape() []int
- func (s *Sin[T]) Parameters() []*graph.Parameter[T]
- type Slice
- func (s *Slice[T]) Attributes() map[string]interface{}
- func (s *Slice[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (s *Slice[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (s *Slice[T]) OpType() string
- func (s *Slice[T]) OutputShape() []int
- func (s *Slice[T]) Parameters() []*graph.Parameter[T]
- type SpectralFingerprint
- func (s *SpectralFingerprint[T]) Attributes() map[string]interface{}
- func (s *SpectralFingerprint[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (s *SpectralFingerprint[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (s *SpectralFingerprint[T]) OpType() string
- func (s *SpectralFingerprint[T]) OutputShape() []int
- func (s *SpectralFingerprint[T]) Parameters() []*graph.Parameter[T]
- type Sqrt
- func (s *Sqrt[T]) Attributes() map[string]any
- func (s *Sqrt[T]) Backward(ctx context.Context, _ types.BackwardMode, dOut *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (s *Sqrt[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (s *Sqrt[T]) OpType() string
- func (s *Sqrt[T]) OutputShape() []int
- func (s *Sqrt[T]) Parameters() []*graph.Parameter[T]
- type Squeeze
- func (s *Squeeze[T]) Attributes() map[string]any
- func (s *Squeeze[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (s *Squeeze[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (s *Squeeze[T]) OpType() string
- func (s *Squeeze[T]) OutputShape() []int
- func (s *Squeeze[T]) Parameters() []*graph.Parameter[T]
- type Sub
- func (s *Sub[T]) Attributes() map[string]interface{}
- func (s *Sub[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (s *Sub[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (s *Sub[T]) OpType() string
- func (s *Sub[T]) OutputShape() []int
- func (s *Sub[T]) Parameters() []*graph.Parameter[T]
- type TemporalConvEncoder
- func (t *TemporalConvEncoder[T]) Attributes() map[string]interface{}
- func (te *TemporalConvEncoder[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (te *TemporalConvEncoder[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (t *TemporalConvEncoder[T]) OpType() string
- func (t *TemporalConvEncoder[T]) OutputShape() []int
- func (te *TemporalConvEncoder[T]) Parameters() []*graph.Parameter[T]
- type Tile
- func (t *Tile[T]) Attributes() map[string]any
- func (t *Tile[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (t *Tile[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (t *Tile[T]) OpType() string
- func (t *Tile[T]) OutputShape() []int
- func (t *Tile[T]) Parameters() []*graph.Parameter[T]
- type TopK
- func (tk *TopK[T]) Attributes() map[string]interface{}
- func (tk *TopK[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (tk *TopK[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (tk *TopK[T]) OpType() string
- func (tk *TopK[T]) OutputShape() []int
- func (tk *TopK[T]) Parameters() []*graph.Parameter[T]
- type Trilu
- func (t *Trilu[T]) Attributes() map[string]any
- func (tr *Trilu[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (tr *Trilu[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (t *Trilu[T]) OpType() string
- func (t *Trilu[T]) OutputShape() []int
- func (t *Trilu[T]) Parameters() []*graph.Parameter[T]
- type Unsqueeze
- func (u *Unsqueeze[T]) Attributes() map[string]interface{}
- func (u *Unsqueeze[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (u *Unsqueeze[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (u *Unsqueeze[T]) OpType() string
- func (u *Unsqueeze[T]) OutputShape() []int
- func (u *Unsqueeze[T]) Parameters() []*graph.Parameter[T]
- type VariableSelection
- func (v *VariableSelection[T]) Attributes() map[string]interface{}
- func (v *VariableSelection[T]) Backward(ctx context.Context, mode types.BackwardMode, ...) ([]*tensor.TensorNumeric[T], error)
- func (v *VariableSelection[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (v *VariableSelection[T]) OpType() string
- func (v *VariableSelection[T]) OutputShape() []int
- func (v *VariableSelection[T]) Parameters() []*graph.Parameter[T]
- type Where
- func (w *Where[T]) Attributes() map[string]any
- func (w *Where[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], ...) ([]*tensor.TensorNumeric[T], error)
- func (w *Where[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (w *Where[T]) OpType() string
- func (w *Where[T]) OutputShape() []int
- func (w *Where[T]) Parameters() []*graph.Parameter[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAdd ¶ added in v0.2.1
func BuildAdd[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], name string, params map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildAdd constructs an Add node from attributes.
func BuildCast ¶ added in v0.2.0
func BuildCast[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]interface{}, ) (graph.Node[T], error)
BuildCast constructs a Cast node.
func BuildConcat ¶ added in v0.2.0
func BuildConcat[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildConcat constructs a Concat node, extracting the axis from attributes.
func BuildConstantOfShape ¶ added in v0.2.1
func BuildConstantOfShape[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attrs map[string]any, ) (graph.Node[T], error)
BuildConstantOfShape constructs a ConstantOfShape node from attributes.
func BuildConv2d ¶ added in v0.2.1
func BuildConv2d[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildConv2d constructs a Conv2d layer from registry attributes. Expects optional int64 or []int64 attributes: "strides", "pads", "dilations", "group".
func BuildCos ¶ added in v0.2.1
func BuildCos[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildCos constructs a Cos node from attributes.
func BuildDiv ¶ added in v0.2.1
func BuildDiv[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildDiv constructs a Div node from attributes.
func BuildEqual ¶ added in v0.2.1
func BuildEqual[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildEqual constructs an Equal node from attributes.
func BuildExpand ¶ added in v0.2.1
func BuildExpand[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildExpand constructs an Expand node from attributes.
func BuildFFN ¶ added in v0.2.1
func BuildFFN[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], name string, params map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildFFN creates an FFN layer from ZMF parameters and attributes.
func BuildFiLM ¶ added in v0.2.1
func BuildFiLM[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], name string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildFiLM constructs a FiLM node from attributes. Required attributes: - "context_dim" (int): dimension of the context input - "feature_dim" (int): dimension of the feature input
func BuildGemm ¶ added in v0.2.1
func BuildGemm[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attrs map[string]any, ) (graph.Node[T], error)
BuildGemm constructs a Gemm node from attributes.
func BuildGlobalAveragePool ¶ added in v0.2.1
func BuildGlobalAveragePool[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]interface{}, ) (graph.Node[T], error)
BuildGlobalAveragePool constructs a GlobalAveragePool node for the layer registry.
func BuildGreater ¶ added in v0.2.1
func BuildGreater[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildGreater constructs a Greater node from attributes.
func BuildLessOrEqual ¶ added in v0.2.1
func BuildLessOrEqual[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildLessOrEqual constructs a LessOrEqual node from attributes.
func BuildMatMul ¶ added in v0.2.0
func BuildMatMul[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]interface{}, ) (graph.Node[T], error)
BuildMatMul constructs a new MatMul node for the given compute engine. It conforms to the layer registry builder signature used by the graph builder.
func BuildMax ¶ added in v0.2.1
func BuildMax[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildMax constructs a Max node from attributes.
func BuildMixtureOfExperts ¶ added in v0.2.1
func BuildMixtureOfExperts[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildMixtureOfExperts constructs a MixtureOfExperts layer from ZMF attributes. Required attributes: "num_experts" (int or int64), "top_k" (int or int64). Note: Expert sub-graphs are not populated (tech debt: ZMF sub-graph support not yet implemented). Experts must be injected manually for real use.
func BuildMoEGate ¶ added in v0.2.1
func BuildMoEGate[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildMoEGate constructs a MoEGate layer from ZMF attributes. Required attribute: "top_k" (int or int64).
func BuildMod ¶ added in v0.2.1
func BuildMod[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildMod constructs a Mod node from attributes.
func BuildMul ¶ added in v0.2.0
func BuildMul[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]interface{}, ) (graph.Node[T], error)
BuildMul constructs a new Mul node for the given compute engine. It conforms to the layer registry builder signature used by the graph builder.
func BuildNeg ¶ added in v0.2.1
func BuildNeg[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildNeg constructs a Neg node from attributes.
func BuildOr ¶ added in v0.2.1
func BuildOr[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildOr constructs an Or node from attributes.
func BuildPad ¶ added in v0.2.1
func BuildPad[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildPad constructs a Pad layer from ZMF attributes. Supported attribute keys: "pads" ([]int64), "constant_value" (float32/float64).
func BuildPow ¶ added in v0.2.1
func BuildPow[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildPow constructs a Pow node from attributes.
func BuildRange ¶ added in v0.2.1
func BuildRange[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildRange constructs a Range node from attributes.
func BuildReduceMean ¶ added in v0.2.1
func BuildReduceMean[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attrs map[string]any, ) (graph.Node[T], error)
BuildReduceMean constructs a ReduceMean node from attributes.
func BuildReshape ¶ added in v0.2.0
func BuildReshape[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildReshape constructs a Reshape node, parsing target shape from attributes.
func BuildResize ¶ added in v0.2.1
func BuildResize[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildResize constructs a Resize layer from registry attributes. Reads "mode" (string), "scales" ([]float64), and/or "sizes" ([]int64). Returns an error if neither scales nor sizes are provided.
func BuildRotaryEmbedding ¶ added in v0.2.0
func BuildRotaryEmbedding[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], name string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildRotaryEmbedding constructs a new RotaryPositionalEmbedding node for the given compute engine. It conforms to the layer registry builder signature used by the graph builder.
func BuildScatterND ¶ added in v0.2.1
func BuildScatterND[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildScatterND constructs a ScatterND node from attributes.
func BuildShape ¶ added in v0.2.0
func BuildShape[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]interface{}, ) (graph.Node[T], error)
BuildShape constructs a new Shape node for the given compute engine. It conforms to the layer registry builder signature used by the graph builder.
func BuildSin ¶ added in v0.2.1
func BuildSin[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildSin constructs a Sin node from attributes.
func BuildSlice ¶ added in v0.2.1
func BuildSlice[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildSlice constructs a Slice layer from ZMF attributes. Supported attribute keys: "starts", "ends", "axes", "steps" (all []int64).
func BuildSpectralFingerprint ¶ added in v0.2.1
func BuildSpectralFingerprint[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildSpectralFingerprint constructs a SpectralFingerprint node from attributes. Required attributes: - "window" (int): window length to analyze (must be > 1) - "top_k" (int): number of non-DC bins to output (must be > 0).
func BuildSqrt ¶ added in v0.2.1
func BuildSqrt[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildSqrt constructs a Sqrt node from attributes.
func BuildSqueeze ¶ added in v0.2.1
func BuildSqueeze[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attrs map[string]any, ) (graph.Node[T], error)
BuildSqueeze constructs a Squeeze node from attributes.
func BuildSub ¶ added in v0.2.0
func BuildSub[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]interface{}, ) (graph.Node[T], error)
BuildSub constructs a new Sub node for the given compute engine. It conforms to the layer registry builder signature used by the graph builder.
func BuildTile ¶ added in v0.2.1
func BuildTile[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], _ map[string]any, ) (graph.Node[T], error)
BuildTile constructs a Tile node from attributes.
func BuildTopK ¶ added in v0.2.1
func BuildTopK[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildTopK constructs a TopK layer from ZMF attributes. Required: "k" (int or int64). Optional: "axis" (int/int64, default -1), "largest" (int64, 1=true, 0=false; default 1), "sorted" (int64; default 1).
func BuildTrilu ¶ added in v0.2.1
func BuildTrilu[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attrs map[string]any, ) (graph.Node[T], error)
BuildTrilu constructs a Trilu node from attributes.
func BuildUnsqueeze ¶ added in v0.2.0
func BuildUnsqueeze[T tensor.Numeric]( engine compute.Engine[T], _ numeric.Arithmetic[T], _ string, _ map[string]*graph.Parameter[T], attributes map[string]interface{}, ) (graph.Node[T], error)
BuildUnsqueeze constructs a new Unsqueeze node for the given compute engine. It parses optional "axes" attributes from the attributes map.
Types ¶
type Add ¶ added in v0.2.1
Add represents an element-wise addition node.
func (*Add[T]) Attributes ¶ added in v0.2.1
Attributes returns the attributes of the Add node.
func (*Add[T]) Backward ¶ added in v0.2.1
func (a *Add[T]) Backward(_ context.Context, mode types.BackwardMode, dOut *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the backward pass of the Add node.
func (*Add[T]) Forward ¶ added in v0.2.1
func (a *Add[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the forward pass of the Add node.
func (*Add[T]) OutputShape ¶ added in v0.2.1
OutputShape returns the output shape of the Add node.
func (*Add[T]) Parameters ¶ added in v0.2.1
Parameters returns the parameters of the Add node.
type Bias ¶
Bias adds a bias vector to its input.
func NewBias ¶
func NewBias[T tensor.Numeric](name string, engine compute.Engine[T], ops numeric.Arithmetic[T], size int, opts ...BiasOption[T]) (*Bias[T], error)
NewBias creates a new Bias layer with default tensor and parameter creation.
func NewBiasFromParam ¶ added in v0.2.0
func NewBiasFromParam[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], biases *graph.Parameter[T]) *Bias[T]
NewBiasFromParam creates a new Bias layer from an existing biases parameter.
func NewBiasWithFactories ¶
func NewBiasWithFactories[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], size int, newTensor func([]int, []T) (*tensor.TensorNumeric[T], error), newParameter func(string, *tensor.TensorNumeric[T], func([]int, []T) (*tensor.TensorNumeric[T], error)) (*graph.Parameter[T], error), initializer func(size int) []T, ) (*Bias[T], error)
NewBiasWithFactories creates a new Bias layer with custom tensor and parameter creation functions.
func (*Bias[T]) Attributes ¶ added in v0.2.0
Attributes returns nil for the Bias layer.
func (*Bias[T]) Backward ¶
func (b *Bias[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients.
func (*Bias[T]) Forward ¶
func (b *Bias[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward performs the forward pass: output = input + biases.
func (*Bias[T]) OutputShape ¶
OutputShape returns the output shape of the Bias layer.
func (*Bias[T]) Parameters ¶
Parameters returns the parameters of the Bias layer.
type BiasOption ¶ added in v0.2.0
type BiasOption[T tensor.Numeric] func(*BiasOptions[T])
BiasOption is a function that applies an option to BiasOptions.
func WithBiasInitializer ¶ added in v0.2.0
func WithBiasInitializer[T tensor.Numeric](initializer func(size int) []T) BiasOption[T]
WithBiasInitializer sets a custom initializer for the bias vector.
type BiasOptions ¶ added in v0.2.0
BiasOptions holds configuration options for the Bias layer.
type Cast ¶ added in v0.2.0
Cast is a layer that converts tensor elements to a different data type.
func (*Cast[T]) Attributes ¶ added in v0.2.0
Attributes returns nil for the Cast layer.
func (*Cast[T]) Backward ¶ added in v0.2.0
func (c *Cast[T]) Backward(_ context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the Cast layer.
func (*Cast[T]) Forward ¶ added in v0.2.0
func (c *Cast[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the cast operation (for same type, this is essentially a copy).
func (*Cast[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the Cast layer.
func (*Cast[T]) Parameters ¶ added in v0.2.0
Parameters returns no trainable parameters for the Cast layer.
type Concat ¶ added in v0.2.0
Concat is a layer that concatenates multiple tensors along a specified axis.
func (*Concat[T]) Attributes ¶ added in v0.2.0
Attributes returns the attributes of the Concat layer.
func (*Concat[T]) Backward ¶ added in v0.2.0
func (c *Concat[T]) Backward(_ context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the Concat layer.
func (*Concat[T]) Forward ¶ added in v0.2.0
func (c *Concat[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the concatenation of input tensors along the specified axis.
func (*Concat[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the Concat layer.
func (*Concat[T]) Parameters ¶ added in v0.2.0
Parameters returns no trainable parameters for the Concat layer.
type Constant ¶ added in v0.2.1
Constant represents a layer that outputs a constant tensor value. This is used for embedding constant tensors from ONNX TENSOR attributes.
func NewConstant ¶ added in v0.2.1
func NewConstant[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], value *tensor.TensorNumeric[T], ) (*Constant[T], error)
NewConstant creates a new Constant layer with the given tensor value.
func NewConstantFromData ¶ added in v0.2.1
func NewConstantFromData[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], shape []int, data []T, ) (*Constant[T], error)
NewConstantFromData creates a new Constant layer with data and shape.
func (*Constant[T]) Attributes ¶ added in v0.2.1
Attributes returns the node's attributes.
func (*Constant[T]) Backward ¶ added in v0.2.1
func (c *Constant[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward performs the backward pass for Constant. Constants produce zero gradients for all inputs since they don't depend on inputs.
func (*Constant[T]) Forward ¶ added in v0.2.1
func (c *Constant[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward performs the forward pass by returning the constant value. The constant value is independent of inputs.
func (*Constant[T]) GetValue ¶ added in v0.2.1
func (c *Constant[T]) GetValue() *tensor.TensorNumeric[T]
GetValue returns the constant tensor value. Useful for inspection and debugging.
func (*Constant[T]) IsMatrix ¶ added in v0.2.1
IsMatrix returns true if the constant is a matrix (2-dimensional tensor).
func (*Constant[T]) IsScalar ¶ added in v0.2.1
IsScalar returns true if the constant is a scalar (0-dimensional tensor).
func (*Constant[T]) IsVector ¶ added in v0.2.1
IsVector returns true if the constant is a vector (1-dimensional tensor).
func (*Constant[T]) NumElements ¶ added in v0.2.1
NumElements returns the total number of elements in the constant tensor.
func (*Constant[T]) OutputShape ¶ added in v0.2.1
OutputShape returns the shape of the output tensor.
func (*Constant[T]) Parameters ¶ added in v0.2.1
Parameters returns the trainable parameters (empty for constant layers).
type ConstantOfShape ¶ added in v0.2.1
ConstantOfShape creates a tensor of a given shape filled with a constant value.
func (*ConstantOfShape[T]) Attributes ¶ added in v0.2.1
func (c *ConstantOfShape[T]) Attributes() map[string]any
func (*ConstantOfShape[T]) Backward ¶ added in v0.2.1
func (c *ConstantOfShape[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*ConstantOfShape[T]) Forward ¶ added in v0.2.1
func (c *ConstantOfShape[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*ConstantOfShape[T]) OpType ¶ added in v0.2.1
func (c *ConstantOfShape[T]) OpType() string
func (*ConstantOfShape[T]) OutputShape ¶ added in v0.2.1
func (c *ConstantOfShape[T]) OutputShape() []int
func (*ConstantOfShape[T]) Parameters ¶ added in v0.2.1
func (c *ConstantOfShape[T]) Parameters() []*graph.Parameter[T]
type Conv1D ¶ added in v0.2.1
Conv1D implements a 1D convolution layer. Input shape: [batch, channels_in, length] Weight shape: [channels_out, channels_in, kernel_size] Output shape: [batch, channels_out, output_length] where output_length = (length + 2*padding - kernel_size) / stride + 1
func NewConv1D ¶ added in v0.2.1
func NewConv1D[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], inChannels, outChannels, kernelSize int, opts ...Conv1DOption, ) (*Conv1D[T], error)
NewConv1D creates a new Conv1D layer.
func (*Conv1D[T]) Attributes ¶ added in v0.2.1
func (*Conv1D[T]) Backward ¶ added in v0.2.1
func (c *Conv1D[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes gradients for Conv1D.
func (*Conv1D[T]) Forward ¶ added in v0.2.1
func (c *Conv1D[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes 1D convolution. Input: [batch, inChannels, length] Output: [batch, outChannels, outputLength]
func (*Conv1D[T]) OutputShape ¶ added in v0.2.1
func (*Conv1D[T]) Parameters ¶ added in v0.2.1
type Conv1DOption ¶ added in v0.2.1
type Conv1DOption func(c interface{})
Conv1DOption configures Conv1D construction.
func Conv1DPadding ¶ added in v0.2.1
func Conv1DPadding(p int) Conv1DOption
Conv1DPadding sets the padding.
func Conv1DStride ¶ added in v0.2.1
func Conv1DStride(s int) Conv1DOption
Conv1DStride sets the stride.
func Conv1DWithoutBias ¶ added in v0.2.1
func Conv1DWithoutBias() Conv1DOption
Conv1DWithoutBias disables bias.
type Conv2d ¶ added in v0.2.1
Conv2d performs 2D convolution (inference-only). Forward expects inputs (X, W [,B]) where:
- X: [N, C_in, H, W]
- W: [C_out, C_in/groups, kH, kW]
- B: [C_out] (optional)
func NewConv2d ¶ added in v0.2.1
func NewConv2d[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], strides []int, pads []int, dilations []int, groups int, ) *Conv2d[T]
NewConv2d creates a Conv2d layer. strides: [strideH, strideW]; pads: [top, left, bottom, right]; dilations: [dH, dW].
func (*Conv2d[T]) Attributes ¶ added in v0.2.1
Attributes returns the layer configuration.
func (*Conv2d[T]) Backward ¶ added in v0.2.1
func (c *Conv2d[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward returns nil (inference-only).
func (*Conv2d[T]) Forward ¶ added in v0.2.1
func (c *Conv2d[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes 2D convolution via im2col + engine.MatMul.
func (*Conv2d[T]) OutputShape ¶ added in v0.2.1
OutputShape returns the output shape (populated after Forward).
func (*Conv2d[T]) Parameters ¶ added in v0.2.1
Parameters returns nil (no embedded trainable parameters).
type Cos ¶ added in v0.2.1
Cos represents an element-wise cosine node.
func (*Cos[T]) Attributes ¶ added in v0.2.1
func (*Cos[T]) Backward ¶ added in v0.2.1
func (c *Cos[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Cos[T]) Forward ¶ added in v0.2.1
func (c *Cos[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Cos[T]) OutputShape ¶ added in v0.2.1
func (*Cos[T]) Parameters ¶ added in v0.2.1
type Dense ¶
Dense is a fully connected layer with optional activation and bias.
func NewDense ¶
func NewDense[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], inputFeatures, outputFeatures int, opts ...DenseOpt[T], ) (*Dense[T], error)
NewDense creates a new Dense layer.
func NewDenseFromParams ¶ added in v0.2.0
NewDenseFromParams creates a Dense layer from existing Linear and Bias components. This is used for constructing layers from pre-existing parameters during model loading.
func (*Dense[T]) Attributes ¶ added in v0.2.0
Attributes returns the attributes of the layer.
func (*Dense[T]) Backward ¶
func (d *Dense[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients.
func (*Dense[T]) Forward ¶
func (d *Dense[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the forward pass of the layer.
func (*Dense[T]) OutputShape ¶
OutputShape returns the output shape of the layer.
func (*Dense[T]) Parameters ¶
Parameters returns the parameters of the layer.
type DenseOpt ¶ added in v0.2.1
DenseOpt is a functional option for configuring a Dense layer.
func WithActivation ¶ added in v0.2.1
WithActivation adds an activation function to the Dense layer.
func WithBias ¶ added in v0.2.0
func WithBias[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], outputFeatures int) DenseOpt[T]
WithBias adds a bias to the Dense layer. The bias is created eagerly; if creation fails the error is stored and surfaced by NewDense.
func WithoutBias ¶ added in v0.2.1
WithoutBias disables bias for the Dense layer.
type Div ¶ added in v0.2.1
Div represents an element-wise division node.
func (*Div[T]) Attributes ¶ added in v0.2.1
func (*Div[T]) Backward ¶ added in v0.2.1
func (d *Div[T]) Backward(ctx context.Context, _ types.BackwardMode, dOut *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Div[T]) Forward ¶ added in v0.2.1
func (d *Div[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Div[T]) OutputShape ¶ added in v0.2.1
func (*Div[T]) Parameters ¶ added in v0.2.1
type Equal ¶ added in v0.2.1
Equal represents an element-wise equality comparison. Output is 1 for true, 0 for false.
func (*Equal[T]) Attributes ¶ added in v0.2.1
func (*Equal[T]) Backward ¶ added in v0.2.1
func (e *Equal[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Equal[T]) Forward ¶ added in v0.2.1
func (e *Equal[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Equal[T]) OutputShape ¶ added in v0.2.1
func (*Equal[T]) Parameters ¶ added in v0.2.1
type Expand ¶ added in v0.2.1
Expand broadcasts a tensor to a target shape.
func (*Expand[T]) Attributes ¶ added in v0.2.1
func (*Expand[T]) Backward ¶ added in v0.2.1
func (e *Expand[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Expand[T]) Forward ¶ added in v0.2.1
func (e *Expand[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Expand[T]) OutputShape ¶ added in v0.2.1
func (*Expand[T]) Parameters ¶ added in v0.2.1
type FFN ¶ added in v0.2.0
FFN is a feed-forward network.
func NewFFN ¶ added in v0.2.0
func NewFFN[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], inputDim, hiddenDim, outputDim int, opts ...FFNOpt[T], ) (*FFN[T], error)
NewFFN creates a new FFN layer.
func (*FFN[T]) Attributes ¶ added in v0.2.0
Attributes returns the attributes of the layer.
func (*FFN[T]) Backward ¶ added in v0.2.0
func (f *FFN[T]) Backward(ctx context.Context, mode types.BackwardMode, dOut *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the backward pass of the FFN.
func (*FFN[T]) Forward ¶ added in v0.2.0
func (f *FFN[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the forward pass of the FFN.
func (*FFN[T]) MergedGateUpParameter ¶ added in v0.2.1
MergedGateUpParameter returns the merged gate+up parameter for GPU upload, or nil if not set.
func (*FFN[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the layer.
func (*FFN[T]) Parameters ¶ added in v0.2.0
Parameters returns the parameters of the layer.
func (*FFN[T]) SetMergedGateUp ¶ added in v0.2.1
func (f *FFN[T]) SetMergedGateUp(weight *tensor.TensorNumeric[T], gateDim, upDim int)
SetMergedGateUp sets a merged gate+up weight tensor for single-GEMV decode optimization. During decode (seqLen=1), a single MatMul replaces two separate gate and up projections.
type FFNOpt ¶ added in v0.2.1
FFNOpt is a functional option for configuring a FFN layer.
func WithFFNNoBias ¶ added in v0.2.1
WithFFNNoBias disables bias for all layers in the FFN.
func WithSwiGLU ¶ added in v0.2.1
WithSwiGLU enables SwiGLU activation.
type FiLM ¶ added in v0.2.1
FiLM (Feature-wise Linear Modulation) layer. It takes a feature tensor and a context tensor as input. It generates scale and bias vectors from the context tensor and applies them to the feature tensor. Output = (feature * scale) + bias
func NewFiLM ¶ added in v0.2.1
func NewFiLM[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], contextDim, featureDim int, ) (*FiLM[T], error)
NewFiLM creates a new FiLM layer.
func (*FiLM[T]) Attributes ¶ added in v0.2.1
Attributes returns the attributes of the FiLM layer.
func (*FiLM[T]) Backward ¶ added in v0.2.1
func (f *FiLM[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the FiLM layer.
func (*FiLM[T]) Forward ¶ added in v0.2.1
func (f *FiLM[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward performs the forward pass for the FiLM layer. It expects two inputs: inputs[0] is the feature tensor, inputs[1] is the context tensor.
func (*FiLM[T]) OutputShape ¶ added in v0.2.1
OutputShape returns the output shape of the FiLM layer.
func (*FiLM[T]) Parameters ¶ added in v0.2.1
Parameters returns the parameters of the FiLM layer.
type Gemm ¶ added in v0.2.1
Gemm implements the ONNX Gemm operator: Y = alpha * A' * B' + beta * C where A' = transpose(A) if transA, B' = transpose(B) if transB.
func (*Gemm[T]) Attributes ¶ added in v0.2.1
func (*Gemm[T]) Backward ¶ added in v0.2.1
func (g *Gemm[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Gemm[T]) Forward ¶ added in v0.2.1
func (g *Gemm[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Gemm[T]) OutputShape ¶ added in v0.2.1
func (*Gemm[T]) Parameters ¶ added in v0.2.1
type GlobalAveragePool ¶ added in v0.2.1
GlobalAveragePool performs global average pooling over the spatial dimensions. Forward expects one 4D input [N, C, H, W] and produces [N, C, 1, 1].
func NewGlobalAveragePool ¶ added in v0.2.1
func NewGlobalAveragePool[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T]) *GlobalAveragePool[T]
NewGlobalAveragePool creates a GlobalAveragePool layer.
func (*GlobalAveragePool[T]) Attributes ¶ added in v0.2.1
func (g *GlobalAveragePool[T]) Attributes() map[string]interface{}
Attributes returns nil.
func (*GlobalAveragePool[T]) Backward ¶ added in v0.2.1
func (g *GlobalAveragePool[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward returns nil (inference-only).
func (*GlobalAveragePool[T]) Forward ¶ added in v0.2.1
func (g *GlobalAveragePool[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes global average pooling.
func (*GlobalAveragePool[T]) OpType ¶ added in v0.2.1
func (g *GlobalAveragePool[T]) OpType() string
OpType returns "GlobalAveragePool".
func (*GlobalAveragePool[T]) OutputShape ¶ added in v0.2.1
func (g *GlobalAveragePool[T]) OutputShape() []int
OutputShape returns the output shape (populated after Forward).
func (*GlobalAveragePool[T]) Parameters ¶ added in v0.2.1
func (g *GlobalAveragePool[T]) Parameters() []*graph.Parameter[T]
Parameters returns nil.
type Greater ¶ added in v0.2.1
Greater represents an element-wise greater-than comparison. Output is 1 for true, 0 for false.
func (*Greater[T]) Attributes ¶ added in v0.2.1
func (*Greater[T]) Backward ¶ added in v0.2.1
func (g *Greater[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Greater[T]) Forward ¶ added in v0.2.1
func (g *Greater[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Greater[T]) OutputShape ¶ added in v0.2.1
func (*Greater[T]) Parameters ¶ added in v0.2.1
type LMHead ¶ added in v0.2.0
LMHead is a linear layer that maps hidden states to vocabulary logits. When tiedWeight is set, it uses MatMulTransposeB to compute the projection directly without an explicit transpose, avoiding a 1GB+ temporary allocation and a use-after-free when the graph's ref-counting releases the transpose output.
func NewLMHead ¶ added in v0.2.0
func NewLMHead[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], hiddenDim, vocabSize int) (*LMHead[T], error)
NewLMHead creates a new LMHead.
func NewTiedLMHead ¶ added in v0.2.1
func NewTiedLMHead[T tensor.Numeric](engine compute.Engine[T], embedWeight *tensor.TensorNumeric[T]) *LMHead[T]
NewTiedLMHead creates an LMHead that reuses an existing embedding weight matrix (shape [vocabSize, hiddenDim]) instead of owning its own weight. Forward transposes the weight and performs the projection.
func (*LMHead[T]) Backward ¶ added in v0.2.0
func (h *LMHead[T]) Backward(ctx context.Context, mode types.BackwardMode, dOut *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the backward pass of the LMHead.
func (*LMHead[T]) Forward ¶ added in v0.2.0
func (h *LMHead[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the forward pass of the LMHead.
func (*LMHead[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the LMHead.
func (*LMHead[T]) Parameters ¶ added in v0.2.0
Parameters returns the parameters of the LMHead. Tied LMHead returns nil since the embedding layer owns the weight.
func (*LMHead[T]) SetWeights ¶ added in v0.2.0
func (h *LMHead[T]) SetWeights(weights *tensor.TensorNumeric[T])
SetWeights sets the weights of the LMHead. This is useful for sharing weights with a token embedding layer.
type LessOrEqual ¶ added in v0.2.1
LessOrEqual represents an element-wise less-than-or-equal comparison. Output is 1 for true, 0 for false.
func (*LessOrEqual[T]) Attributes ¶ added in v0.2.1
func (l *LessOrEqual[T]) Attributes() map[string]any
func (*LessOrEqual[T]) Backward ¶ added in v0.2.1
func (l *LessOrEqual[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*LessOrEqual[T]) Forward ¶ added in v0.2.1
func (l *LessOrEqual[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*LessOrEqual[T]) OpType ¶ added in v0.2.1
func (l *LessOrEqual[T]) OpType() string
func (*LessOrEqual[T]) OutputShape ¶ added in v0.2.1
func (l *LessOrEqual[T]) OutputShape() []int
func (*LessOrEqual[T]) Parameters ¶ added in v0.2.1
func (l *LessOrEqual[T]) Parameters() []*graph.Parameter[T]
type Linear ¶
Linear is a linear layer.
func NewLinear ¶
func NewLinear[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], inputFeatures, outputFeatures int, ) (*Linear[T], error)
NewLinear creates a new Linear layer.
func NewLinearFromParam ¶ added in v0.2.0
func NewLinearFromParam[T tensor.Numeric](engine compute.Engine[T], param *graph.Parameter[T]) *Linear[T]
NewLinearFromParam creates a Linear layer from an existing parameter. This is used for constructing layers from pre-existing parameters during model loading.
func (*Linear[T]) Attributes ¶ added in v0.2.0
Attributes returns the attributes of the layer.
func (*Linear[T]) Backward ¶
func (l *Linear[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients.
func (*Linear[T]) Forward ¶
func (l *Linear[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the forward pass of the layer.
func (*Linear[T]) OutputShape ¶
OutputShape returns the output shape of the layer.
func (*Linear[T]) Parameters ¶
Parameters returns the parameters of the layer.
type MatMul ¶ added in v0.2.0
MatMul is a layer that performs matrix multiplication of two tensors.
func (*MatMul[T]) Attributes ¶ added in v0.2.0
Attributes returns nil for the MatMul layer.
func (*MatMul[T]) Backward ¶ added in v0.2.0
func (m *MatMul[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the MatMul layer.
func (*MatMul[T]) Forward ¶ added in v0.2.0
func (m *MatMul[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the matrix multiplication.
func (*MatMul[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the MatMul layer.
func (*MatMul[T]) Parameters ¶ added in v0.2.0
Parameters returns no trainable parameters for the MatMul layer.
type MatMulNBits ¶ added in v0.2.1
MatMulNBits represents a matrix multiplication layer with N-bit quantized weights. This is commonly used for 4-bit quantized models like Gemma 3.
The layer performs: output = input @ dequantize(quantized_weights) Where dequantize unpacks N-bit weights and applies scale/zero-point transformation.
func NewMatMulNBits ¶ added in v0.2.1
func NewMatMulNBits[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], quantizedWeights *tensor.TensorNumeric[uint8], scale *tensor.TensorNumeric[T], zeroPoint *tensor.TensorNumeric[uint8], nbits int, symmetric bool, ) (*MatMulNBits[T], error)
NewMatMulNBits creates a new N-bit quantized matrix multiplication layer.
func (*MatMulNBits[T]) Attributes ¶ added in v0.2.1
func (m *MatMulNBits[T]) Attributes() map[string]interface{}
Attributes returns the node's non-tensor attributes.
func (*MatMulNBits[T]) Backward ¶ added in v0.2.1
func (m *MatMulNBits[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward performs the backward pass for MatMulNBits. Computes gradients with respect to input (weights are quantized and typically frozen).
func (*MatMulNBits[T]) Forward ¶ added in v0.2.1
func (m *MatMulNBits[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward performs the forward pass: output = input @ dequantized_weights
func (*MatMulNBits[T]) GetDequantizedWeights ¶ added in v0.2.1
func (m *MatMulNBits[T]) GetDequantizedWeights() (*tensor.TensorNumeric[T], error)
GetDequantizedWeights returns the cached dequantized weights for inspection. Useful for debugging and testing.
func (*MatMulNBits[T]) InvalidateCache ¶ added in v0.2.1
func (m *MatMulNBits[T]) InvalidateCache()
InvalidateCache marks the dequantized weights cache as invalid. Call this if quantized weights, scale, or zero point are modified.
func (*MatMulNBits[T]) OpType ¶ added in v0.2.1
func (m *MatMulNBits[T]) OpType() string
OpType returns the operation type of the node.
func (*MatMulNBits[T]) OutputShape ¶ added in v0.2.1
func (m *MatMulNBits[T]) OutputShape() []int
OutputShape returns the shape of the output tensor.
func (*MatMulNBits[T]) Parameters ¶ added in v0.2.1
func (m *MatMulNBits[T]) Parameters() []*graph.Parameter[T]
Parameters returns the trainable parameters (empty for quantized layers).
func (*MatMulNBits[T]) QuantizationInfo ¶ added in v0.2.1
func (m *MatMulNBits[T]) QuantizationInfo() map[string]interface{}
QuantizationInfo returns information about the quantization configuration.
func (*MatMulNBits[T]) String ¶ added in v0.2.1
func (m *MatMulNBits[T]) String() string
String returns a string representation of the layer.
type Max ¶ added in v0.2.1
Max computes the element-wise maximum of two tensors.
func (*Max[T]) Attributes ¶ added in v0.2.1
func (*Max[T]) Backward ¶ added in v0.2.1
func (m *Max[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Max[T]) Forward ¶ added in v0.2.1
func (m *Max[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Max[T]) OutputShape ¶ added in v0.2.1
func (*Max[T]) Parameters ¶ added in v0.2.1
type MixtureOfExperts ¶ added in v0.2.1
MixtureOfExperts routes each token to topK experts selected by MoEGate and returns the weighted sum of expert outputs.
Forward expects exactly two inputs:
- hiddenStates [seqLen, modelDim]
- gateWeight [numExperts, modelDim]
Experts must be set at construction time as graph.Node[T] instances. Tech debt: ZMF sub-graph loading is not yet supported; experts are not populated by BuildMixtureOfExperts.
func NewMixtureOfExperts ¶ added in v0.2.1
func NewMixtureOfExperts[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], gate *MoEGate[T], experts []graph.Node[T], numExperts, topK int, ) *MixtureOfExperts[T]
NewMixtureOfExperts creates a MixtureOfExperts layer.
func (*MixtureOfExperts[T]) Attributes ¶ added in v0.2.1
func (m *MixtureOfExperts[T]) Attributes() map[string]any
Attributes returns the layer configuration.
func (*MixtureOfExperts[T]) Backward ¶ added in v0.2.1
func (m *MixtureOfExperts[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes gradients for the MixtureOfExperts layer.
The forward computation is:
output[t] = sum_k(weights[t][k] * expert_k(hiddenStates[t]))
where weights come from softmax + top-K + normalize on router logits.
Backward pass:
- dX from experts: sum_k(weights[k] * dOut) — assuming identity-like expert gradients
- dWeights: for each selected expert k, dot(dOut[t], expert_k(x[t]))
- Route dWeights through the gate backward (softmax + STE for top-K)
Inputs must match forward: [hiddenStates, gateWeight]. Returns gradients [dHiddenStates, dGateWeight].
func (*MixtureOfExperts[T]) Forward ¶ added in v0.2.1
func (m *MixtureOfExperts[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward routes tokens to topK experts and returns the weighted sum [seqLen, modelDim]. For batch sizes > 1, tokens are grouped by expert and processed in batched forward calls instead of sequential per-token dispatch.
func (*MixtureOfExperts[T]) OpType ¶ added in v0.2.1
func (m *MixtureOfExperts[T]) OpType() string
OpType returns "MixtureOfExperts".
func (*MixtureOfExperts[T]) OutputShape ¶ added in v0.2.1
func (m *MixtureOfExperts[T]) OutputShape() []int
OutputShape returns the output shape from the last forward call.
func (*MixtureOfExperts[T]) Parameters ¶ added in v0.2.1
func (m *MixtureOfExperts[T]) Parameters() []*graph.Parameter[T]
Parameters returns nil (no trainable parameters).
type MoEGate ¶ added in v0.2.1
MoEGate computes sparse top-k expert routing for Mixture of Experts.
Forward expects exactly two inputs:
- hiddenStates [seqLen, modelDim]
- gateWeight [numExperts, modelDim]
Steps:
- logits = hiddenStates @ gateWeight.T -> [seqLen, numExperts]
- probs = Softmax(logits, axis=1) -> [seqLen, numExperts]
- For each token row: pick topK indices by descending probability.
- Normalize the topK scores so each row sums to 1.0.
Returns a [seqLen, topK] tensor of normalized expert weights.
func NewMoEGate ¶ added in v0.2.1
func NewMoEGate[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], topK int) *MoEGate[T]
NewMoEGate creates a MoEGate layer with the given topK value.
func (*MoEGate[T]) Attributes ¶ added in v0.2.1
Attributes returns the gate configuration.
func (*MoEGate[T]) Backward ¶ added in v0.2.1
func (g *MoEGate[T]) Backward(_ context.Context, _ types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes gradients for the MoE gate using the straight-through estimator.
The top-K selection is a discrete operation. STE treats it as identity in the backward pass: gradients flow through the softmax as if all experts were selected, but only the top-K experts receive non-zero upstream gradient from the MoE output.
Inputs must match the forward call: [hiddenStates, gateWeight]. outputGradient has shape [seqLen, topK] — gradient w.r.t. the normalized gate weights.
Returns gradients [dHiddenStates, dGateWeight].
func (*MoEGate[T]) Forward ¶ added in v0.2.1
func (g *MoEGate[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward returns normalized expert weights shaped [seqLen, topK].
func (*MoEGate[T]) OutputShape ¶ added in v0.2.1
OutputShape returns the output shape from the last forward call.
func (*MoEGate[T]) Parameters ¶ added in v0.2.1
Parameters returns nil (no trainable parameters).
type Mod ¶ added in v0.2.1
Mod computes element-wise remainder (fmod). Supports scalar broadcasting. ONNX Mod op with fmod=1 (default for floats).
func (*Mod[T]) Attributes ¶ added in v0.2.1
func (*Mod[T]) Backward ¶ added in v0.2.1
func (m *Mod[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Mod[T]) Forward ¶ added in v0.2.1
func (m *Mod[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Mod[T]) OutputShape ¶ added in v0.2.1
func (*Mod[T]) Parameters ¶ added in v0.2.1
type Mul ¶ added in v0.2.0
Mul is a layer that performs element-wise multiplication of two tensors.
func (*Mul[T]) Attributes ¶ added in v0.2.0
Attributes returns nil for the Mul layer.
func (*Mul[T]) Backward ¶ added in v0.2.0
func (m *Mul[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the Mul layer.
func (*Mul[T]) Forward ¶ added in v0.2.0
func (m *Mul[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the element-wise multiplication of two input tensors.
func (*Mul[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the Mul layer.
func (*Mul[T]) Parameters ¶ added in v0.2.0
Parameters returns no trainable parameters for the Mul layer.
type Neg ¶ added in v0.2.1
Neg represents an element-wise negation node.
func (*Neg[T]) Attributes ¶ added in v0.2.1
func (*Neg[T]) Backward ¶ added in v0.2.1
func (n *Neg[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Neg[T]) Forward ¶ added in v0.2.1
func (n *Neg[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Neg[T]) OutputShape ¶ added in v0.2.1
func (*Neg[T]) Parameters ¶ added in v0.2.1
type Or ¶ added in v0.2.1
Or represents an element-wise logical OR. Output is 1 when either input is nonzero, 0 otherwise.
func (*Or[T]) Attributes ¶ added in v0.2.1
func (*Or[T]) Backward ¶ added in v0.2.1
func (o *Or[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Or[T]) Forward ¶ added in v0.2.1
func (o *Or[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Or[T]) OutputShape ¶ added in v0.2.1
func (*Or[T]) Parameters ¶ added in v0.2.1
type Pad ¶ added in v0.2.1
Pad applies constant-value padding to a tensor. pads has shape [2*ndim]: [begin_0, begin_1, ..., end_0, end_1, ...].
func (*Pad[T]) Attributes ¶ added in v0.2.1
Attributes returns the pad configuration.
func (*Pad[T]) Backward ¶ added in v0.2.1
func (p *Pad[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward returns nil (not required for inference).
func (*Pad[T]) Forward ¶ added in v0.2.1
func (p *Pad[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward pads the input tensor with the configured constant value.
func (*Pad[T]) OutputShape ¶ added in v0.2.1
OutputShape returns the output shape from the last forward call.
func (*Pad[T]) Parameters ¶ added in v0.2.1
Parameters returns nil (no trainable parameters).
type PolynomialExpansion ¶
PolynomialExpansion layer transforms input features into polynomial combinations up to a specified degree. This is useful for capturing non-linear relationships in data through feature engineering.
For input [x1, x2] with degree 2, it generates: [1, x1, x2, x1^2, x1*x2, x2^2]
The layer supports: - Configurable polynomial degree - Optional bias term (constant 1) - Interaction terms between features - Efficient computation using tensor operations.
func NewPolynomialExpansion ¶
func NewPolynomialExpansion[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], inputSize int, options ...PolynomialExpansionOption[T], ) (*PolynomialExpansion[T], error)
NewPolynomialExpansion creates a new polynomial expansion layer.
Parameters: - name: layer name (currently not used but kept for consistency) - engine: compute engine for tensor operations - ops: arithmetic operations for the numeric type - inputSize: number of input features - options: functional options for configuration
Default values: - degree: 2 - includeBias: true
Returns the polynomial expansion layer or an error if parameters are invalid.
func (*PolynomialExpansion[T]) Attributes ¶ added in v0.2.0
func (p *PolynomialExpansion[T]) Attributes() map[string]interface{}
Attributes returns the attributes of the PolynomialExpansion layer.
func (*PolynomialExpansion[T]) Backward ¶
func (p *PolynomialExpansion[T]) Backward(_ context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes gradients for the polynomial expansion layer. This computes the derivative of each polynomial term with respect to the input features.
func (*PolynomialExpansion[T]) Forward ¶
func (p *PolynomialExpansion[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward performs the polynomial expansion transformation. Input shape: [batch_size, input_size] Output shape: [batch_size, output_size].
func (*PolynomialExpansion[T]) GetDegree ¶
func (p *PolynomialExpansion[T]) GetDegree() int
GetDegree returns the polynomial degree of the layer.
func (*PolynomialExpansion[T]) GetInputSize ¶
func (p *PolynomialExpansion[T]) GetInputSize() int
GetInputSize returns the input size of the layer.
func (*PolynomialExpansion[T]) GetOutputSize ¶
func (p *PolynomialExpansion[T]) GetOutputSize() int
GetOutputSize returns the output size of the layer.
func (*PolynomialExpansion[T]) GetTermIndices ¶
func (p *PolynomialExpansion[T]) GetTermIndices() [][]int
GetTermIndices returns the polynomial term indices for inspection/debugging.
func (*PolynomialExpansion[T]) HasBias ¶
func (p *PolynomialExpansion[T]) HasBias() bool
HasBias returns whether the layer includes a bias term.
func (*PolynomialExpansion[T]) OpType ¶ added in v0.2.0
func (p *PolynomialExpansion[T]) OpType() string
OpType returns the operation type of the PolynomialExpansion layer.
func (*PolynomialExpansion[T]) OutputShape ¶
func (p *PolynomialExpansion[T]) OutputShape() []int
OutputShape returns the shape of the output tensor.
func (*PolynomialExpansion[T]) Parameters ¶
func (p *PolynomialExpansion[T]) Parameters() []*graph.Parameter[T]
Parameters returns the parameters of the layer. Polynomial expansion has no trainable parameters.
func (*PolynomialExpansion[T]) SetName ¶
func (p *PolynomialExpansion[T]) SetName(_ string)
SetName sets the name of the layer (for consistency with other layers). SetName sets the name of the layer (for consistency with other layers).
type PolynomialExpansionOption ¶ added in v0.2.0
type PolynomialExpansionOption[T tensor.Numeric] func(*PolynomialExpansionOptions[T])
PolynomialExpansionOption is a function that configures PolynomialExpansionOptions.
func WithPolynomialBias ¶ added in v0.2.0
func WithPolynomialBias[T tensor.Numeric](includeBias bool) PolynomialExpansionOption[T]
WithPolynomialBias sets whether to include a bias term (constant 1).
func WithPolynomialDegree ¶ added in v0.2.0
func WithPolynomialDegree[T tensor.Numeric](degree int) PolynomialExpansionOption[T]
WithPolynomialDegree sets the maximum polynomial degree.
type PolynomialExpansionOptions ¶ added in v0.2.0
PolynomialExpansionOptions holds configuration options for PolynomialExpansion layer.
type PoolMode ¶ added in v1.9.0
type PoolMode int
PoolMode determines how token hidden states are aggregated into a fixed-size representation before classification.
const ( // PoolCLS takes the hidden state of the first token (index 0) as the // sequence representation. This is the standard approach for BERT-style // models where a [CLS] token is prepended. PoolCLS PoolMode = iota // PoolMean computes the mean of all token hidden states across the // sequence dimension to produce the sequence representation. PoolMean )
type Pow ¶ added in v0.2.1
Pow represents an element-wise power node.
func (*Pow[T]) Attributes ¶ added in v0.2.1
func (*Pow[T]) Backward ¶ added in v0.2.1
func (p *Pow[T]) Backward(ctx context.Context, _ types.BackwardMode, dOut *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Pow[T]) Forward ¶ added in v0.2.1
func (p *Pow[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Pow[T]) OutputShape ¶ added in v0.2.1
func (*Pow[T]) Parameters ¶ added in v0.2.1
type Range ¶ added in v0.2.1
Range generates a sequence of numbers [start, limit) with given delta.
func (*Range[T]) Attributes ¶ added in v0.2.1
func (*Range[T]) Backward ¶ added in v0.2.1
func (r *Range[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Range[T]) Forward ¶ added in v0.2.1
func (r *Range[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Range[T]) OutputShape ¶ added in v0.2.1
func (*Range[T]) Parameters ¶ added in v0.2.1
type ReduceMean ¶ added in v0.2.1
ReduceMean reduces a tensor by computing the mean along specified axes.
func (*ReduceMean[T]) Attributes ¶ added in v0.2.1
func (r *ReduceMean[T]) Attributes() map[string]any
func (*ReduceMean[T]) Backward ¶ added in v0.2.1
func (r *ReduceMean[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*ReduceMean[T]) Forward ¶ added in v0.2.1
func (r *ReduceMean[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*ReduceMean[T]) OpType ¶ added in v0.2.1
func (r *ReduceMean[T]) OpType() string
func (*ReduceMean[T]) OutputShape ¶ added in v0.2.1
func (r *ReduceMean[T]) OutputShape() []int
func (*ReduceMean[T]) Parameters ¶ added in v0.2.1
func (r *ReduceMean[T]) Parameters() []*graph.Parameter[T]
type Reshape ¶ added in v0.2.0
Reshape is a layer that changes the shape of a tensor without changing its data.
func NewReshape ¶ added in v0.2.0
NewReshape creates a new Reshape layer.
func (*Reshape[T]) Attributes ¶ added in v0.2.0
Attributes returns the attributes of the Reshape layer.
func (*Reshape[T]) Backward ¶ added in v0.2.0
func (r *Reshape[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the Reshape layer.
func (*Reshape[T]) Forward ¶ added in v0.2.0
func (r *Reshape[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the reshape operation. Accepts 1 input (static target shape from attributes) or 2 inputs (ONNX opset 5+: data + shape tensor). In the shape tensor, -1 means infer and 0 means copy from the corresponding input dimension.
func (*Reshape[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the Reshape layer.
func (*Reshape[T]) Parameters ¶ added in v0.2.0
Parameters returns no trainable parameters for the Reshape layer.
type Resize ¶ added in v0.2.1
Resize resamples a 4D input tensor to a new spatial size. Only nearest-neighbor interpolation is implemented. Either scales or sizes (but not both) must be provided at build time. Forward expects exactly one input: X [N, C, H, W].
func NewResize ¶ added in v0.2.1
func NewResize[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], mode string, scales []float64, sizes []int64, ) *Resize[T]
NewResize creates a Resize layer. Provide either non-nil scales or non-nil sizes (not both).
func (*Resize[T]) Attributes ¶ added in v0.2.1
Attributes returns the resize configuration.
func (*Resize[T]) Backward ¶ added in v0.2.1
func (r *Resize[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward returns nil (inference-only).
func (*Resize[T]) Forward ¶ added in v0.2.1
func (r *Resize[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward resamples X to the target spatial size.
func (*Resize[T]) OutputShape ¶ added in v0.2.1
OutputShape returns the output shape (populated after Forward).
func (*Resize[T]) Parameters ¶ added in v0.2.1
Parameters returns nil.
type RotaryEmbedding ¶ added in v0.2.0
RotaryEmbedding applies rotary position embedding to input tensors.
func NewRotaryEmbedding ¶ added in v0.2.0
func NewRotaryEmbedding[T tensor.Numeric](engine compute.Engine[T]) *RotaryEmbedding[T]
NewRotaryEmbedding creates a new RotaryEmbedding layer.
func (*RotaryEmbedding[T]) Attributes ¶ added in v0.2.0
func (r *RotaryEmbedding[T]) Attributes() map[string]interface{}
Attributes returns nil for the RotaryEmbedding layer.
func (*RotaryEmbedding[T]) Backward ¶ added in v0.2.0
func (r *RotaryEmbedding[T]) Backward(_ context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the RotaryEmbedding layer.
func (*RotaryEmbedding[T]) Forward ¶ added in v0.2.0
func (r *RotaryEmbedding[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward applies rotary embedding to the input.
func (*RotaryEmbedding[T]) Name ¶ added in v0.2.0
func (r *RotaryEmbedding[T]) Name() string
Name returns the name of the layer.
func (*RotaryEmbedding[T]) OpType ¶ added in v0.2.0
func (r *RotaryEmbedding[T]) OpType() string
OpType returns the operation type of the RotaryEmbedding layer.
func (*RotaryEmbedding[T]) OutputShape ¶ added in v0.2.0
func (r *RotaryEmbedding[T]) OutputShape() []int
OutputShape returns the output shape of the layer.
func (*RotaryEmbedding[T]) Parameters ¶ added in v0.2.0
func (r *RotaryEmbedding[T]) Parameters() []*graph.Parameter[T]
Parameters returns the parameters of the layer (none for RotaryEmbedding).
func (*RotaryEmbedding[T]) SetName ¶ added in v0.2.0
func (r *RotaryEmbedding[T]) SetName(name string)
SetName sets the name of the layer.
type ScatterND ¶ added in v0.2.1
ScatterND scatters updates into a copy of the data tensor at indices.
func (*ScatterND[T]) Attributes ¶ added in v0.2.1
func (*ScatterND[T]) Backward ¶ added in v0.2.1
func (s *ScatterND[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*ScatterND[T]) Forward ¶ added in v0.2.1
func (s *ScatterND[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*ScatterND[T]) OutputShape ¶ added in v0.2.1
func (*ScatterND[T]) Parameters ¶ added in v0.2.1
type SeqClassification ¶ added in v1.9.0
SeqClassification is a sequence classification head that pools token-level hidden states into a fixed-size vector and projects it to class logits.
Forward expects input of shape [batch, seqLen, hiddenDim] and produces output of shape [batch, numClasses].
func NewSeqClassification ¶ added in v1.9.0
func NewSeqClassification[T tensor.Float]( engine compute.Engine[T], ops numeric.Arithmetic[T], poolMode PoolMode, hiddenDim, numClasses int, opts ...SeqClassificationOpt[T], ) (*SeqClassification[T], error)
NewSeqClassification creates a new sequence classification head.
func (*SeqClassification[T]) Attributes ¶ added in v1.9.0
func (s *SeqClassification[T]) Attributes() map[string]interface{}
Attributes returns the layer attributes.
func (*SeqClassification[T]) Backward ¶ added in v1.9.0
func (s *SeqClassification[T]) Backward(ctx context.Context, mode types.BackwardMode, dOut *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the backward pass.
func (*SeqClassification[T]) Forward ¶ added in v1.9.0
func (s *SeqClassification[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the forward pass. Input shape: [batch, seqLen, hiddenDim] -> Output shape: [batch, numClasses].
func (*SeqClassification[T]) OpType ¶ added in v1.9.0
func (s *SeqClassification[T]) OpType() string
OpType returns "SeqClassification".
func (*SeqClassification[T]) OutputShape ¶ added in v1.9.0
func (s *SeqClassification[T]) OutputShape() []int
OutputShape returns the output shape from the most recent Forward call.
func (*SeqClassification[T]) Parameters ¶ added in v1.9.0
func (s *SeqClassification[T]) Parameters() []*graph.Parameter[T]
Parameters returns the trainable parameters (from the Dense layer).
func (*SeqClassification[T]) SetTraining ¶ added in v1.9.0
func (s *SeqClassification[T]) SetTraining(training bool)
SetTraining enables or disables training mode on the dropout sub-layer.
type SeqClassificationOpt ¶ added in v1.9.0
type SeqClassificationOpt[T tensor.Float] func(*SeqClassification[T])
SeqClassificationOpt is a functional option for configuring a SeqClassification layer.
func WithDropout ¶ added in v1.9.0
func WithDropout[T tensor.Float](engine compute.Engine[T], ops numeric.Arithmetic[T], rate T) SeqClassificationOpt[T]
WithDropout adds dropout before the linear projection with the given rate.
type Shape ¶ added in v0.2.0
Shape is a layer that outputs the shape of its input tensor.
func (*Shape[T]) Attributes ¶ added in v0.2.0
Attributes returns nil for the Shape layer.
func (*Shape[T]) Backward ¶ added in v0.2.0
func (s *Shape[T]) Backward(_ context.Context, mode types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the Shape layer.
func (*Shape[T]) Forward ¶ added in v0.2.0
func (s *Shape[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the shape of the input tensor.
func (*Shape[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the Shape layer.
func (*Shape[T]) Parameters ¶ added in v0.2.0
Parameters returns no trainable parameters for the Shape layer.
type Sin ¶ added in v0.2.1
Sin represents an element-wise sine node.
func (*Sin[T]) Attributes ¶ added in v0.2.1
func (*Sin[T]) Backward ¶ added in v0.2.1
func (s *Sin[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Sin[T]) Forward ¶ added in v0.2.1
func (s *Sin[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Sin[T]) OutputShape ¶ added in v0.2.1
func (*Sin[T]) Parameters ¶ added in v0.2.1
type Slice ¶ added in v0.2.1
Slice extracts a sub-tensor using start/end/axes/steps attributes. Steps other than 1 are not supported; steps are accepted but ignored.
func NewSlice ¶ added in v0.2.1
func NewSlice[T tensor.Numeric](engine compute.Engine[T], starts, ends, axes, steps []int64) *Slice[T]
NewSlice creates a new Slice layer.
func (*Slice[T]) Attributes ¶ added in v0.2.1
Attributes returns the slice configuration.
func (*Slice[T]) Backward ¶ added in v0.2.1
func (s *Slice[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward returns nil (not required for inference).
func (*Slice[T]) Forward ¶ added in v0.2.1
func (s *Slice[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward applies the slice operation to the input tensor. Accepts 1 input (attribute-based, opset 1-9) or 3-5 inputs (ONNX opset 10+: data, starts, ends, [axes], [steps]).
func (*Slice[T]) OutputShape ¶ added in v0.2.1
OutputShape returns the output shape from the last forward call.
func (*Slice[T]) Parameters ¶ added in v0.2.1
Parameters returns nil (no trainable parameters).
type SpectralFingerprint ¶ added in v0.2.1
SpectralFingerprint implements a layer that extracts the top-K frequency components from the input using FFT, creating a fixed-size spectral signature for variable-length inputs.
func NewSpectralFingerprint ¶ added in v0.2.1
func NewSpectralFingerprint[T tensor.Numeric](engine compute.Engine[T], ops numeric.Arithmetic[T], window, topK int) (*SpectralFingerprint[T], error)
NewSpectralFingerprint creates a new SpectralFingerprint layer.
func (*SpectralFingerprint[T]) Attributes ¶ added in v0.2.1
func (s *SpectralFingerprint[T]) Attributes() map[string]interface{}
Attributes returns the attributes of the layer.
func (*SpectralFingerprint[T]) Backward ¶ added in v0.2.1
func (s *SpectralFingerprint[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward returns no gradients (treated as non-differentiable feature transform).
func (*SpectralFingerprint[T]) Forward ¶ added in v0.2.1
func (s *SpectralFingerprint[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes spectral magnitudes for bins 1..topK for each row in the batch. Input must be [batch, window]. If input window dimension is larger than the configured window, only the last `window` elements are used. If smaller, an error is returned.
func (*SpectralFingerprint[T]) OpType ¶ added in v0.2.1
func (s *SpectralFingerprint[T]) OpType() string
OpType returns the operation type.
func (*SpectralFingerprint[T]) OutputShape ¶ added in v0.2.1
func (s *SpectralFingerprint[T]) OutputShape() []int
OutputShape returns the last computed output shape.
func (*SpectralFingerprint[T]) Parameters ¶ added in v0.2.1
func (s *SpectralFingerprint[T]) Parameters() []*graph.Parameter[T]
Parameters returns no trainable parameters for SpectralFingerprint.
type Sqrt ¶ added in v0.2.1
Sqrt represents an element-wise square root node.
func (*Sqrt[T]) Attributes ¶ added in v0.2.1
func (*Sqrt[T]) Backward ¶ added in v0.2.1
func (s *Sqrt[T]) Backward(ctx context.Context, _ types.BackwardMode, dOut *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Sqrt[T]) Forward ¶ added in v0.2.1
func (s *Sqrt[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Sqrt[T]) OutputShape ¶ added in v0.2.1
func (*Sqrt[T]) Parameters ¶ added in v0.2.1
type Squeeze ¶ added in v0.2.1
Squeeze removes dimensions of size 1 at the specified axes. If no axes are specified, all size-1 dimensions are removed.
func (*Squeeze[T]) Attributes ¶ added in v0.2.1
func (*Squeeze[T]) Backward ¶ added in v0.2.1
func (s *Squeeze[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Squeeze[T]) Forward ¶ added in v0.2.1
func (s *Squeeze[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Squeeze[T]) OutputShape ¶ added in v0.2.1
func (*Squeeze[T]) Parameters ¶ added in v0.2.1
type Sub ¶ added in v0.2.0
Sub is a layer that performs element-wise subtraction of two tensors.
func (*Sub[T]) Attributes ¶ added in v0.2.0
Attributes returns nil for the Sub layer.
func (*Sub[T]) Backward ¶ added in v0.2.0
func (s *Sub[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the Sub layer.
func (*Sub[T]) Forward ¶ added in v0.2.0
func (s *Sub[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the element-wise subtraction of two input tensors (a - b).
func (*Sub[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the Sub layer.
func (*Sub[T]) Parameters ¶ added in v0.2.0
Parameters returns no trainable parameters for the Sub layer.
type TemporalConvEncoder ¶ added in v0.2.1
TemporalConvEncoder replaces the non-differentiable SpectralFingerprint. Two stacked Conv1D layers with ReLU + global average pool + linear projection.
Input: [batch, numStats, windowSize] (per-era group stats over time) Output: [batch, outputDim]
Pipeline:
conv1 = Conv1D(numStats, hiddenChannels, kernel=3, pad=1) + ReLU conv2 = Conv1D(hiddenChannels, hiddenChannels, kernel=3, pad=1) + ReLU pooled = ReduceMean(conv2_out, axis=2) -- global average pool output = Linear(hiddenChannels, outputDim)
func NewTemporalConvEncoder ¶ added in v0.2.1
func NewTemporalConvEncoder[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], numStats, hiddenChannels, outputDim int, ) (*TemporalConvEncoder[T], error)
NewTemporalConvEncoder creates a new TemporalConvEncoder.
func (*TemporalConvEncoder[T]) Attributes ¶ added in v0.2.1
func (t *TemporalConvEncoder[T]) Attributes() map[string]interface{}
func (*TemporalConvEncoder[T]) Backward ¶ added in v0.2.1
func (te *TemporalConvEncoder[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes gradients through the encoder.
func (*TemporalConvEncoder[T]) Forward ¶ added in v0.2.1
func (te *TemporalConvEncoder[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward processes temporal group statistics through conv layers.
func (*TemporalConvEncoder[T]) OpType ¶ added in v0.2.1
func (t *TemporalConvEncoder[T]) OpType() string
func (*TemporalConvEncoder[T]) OutputShape ¶ added in v0.2.1
func (t *TemporalConvEncoder[T]) OutputShape() []int
func (*TemporalConvEncoder[T]) Parameters ¶ added in v0.2.1
func (te *TemporalConvEncoder[T]) Parameters() []*graph.Parameter[T]
Parameters returns all trainable parameters.
type Tile ¶ added in v0.2.1
Tile repeats a tensor along each dimension according to the repeats tensor. ONNX Tile op: output[i] = input[i % input_shape[dim]] for each dim.
func (*Tile[T]) Attributes ¶ added in v0.2.1
func (*Tile[T]) Backward ¶ added in v0.2.1
func (t *Tile[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Tile[T]) Forward ¶ added in v0.2.1
func (t *Tile[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Tile[T]) OutputShape ¶ added in v0.2.1
func (*Tile[T]) Parameters ¶ added in v0.2.1
type TopK ¶ added in v0.2.1
TopK selects the top-k values along the last axis of the input tensor. It returns only the values (not indices) as a single output tensor. When largest=true (default) it returns the k largest values in descending order; when largest=false it returns the k smallest values in ascending order.
func NewTopK ¶ added in v0.2.1
func NewTopK[T tensor.Numeric](engine compute.Engine[T], k, axis int, largest, sorted bool) *TopK[T]
NewTopK creates a new TopK layer.
func (*TopK[T]) Attributes ¶ added in v0.2.1
Attributes returns the TopK configuration.
func (*TopK[T]) Backward ¶ added in v0.2.1
func (tk *TopK[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward returns nil (not required for inference).
func (*TopK[T]) Forward ¶ added in v0.2.1
func (tk *TopK[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward selects the top-k values along the last axis of the input.
func (*TopK[T]) OutputShape ¶ added in v0.2.1
OutputShape returns the output shape from the last forward call.
func (*TopK[T]) Parameters ¶ added in v0.2.1
Parameters returns nil (no trainable parameters).
type Trilu ¶ added in v0.2.1
Trilu extracts the upper or lower triangular part of a 2D matrix (or batch of matrices).
func (*Trilu[T]) Attributes ¶ added in v0.2.1
func (*Trilu[T]) Backward ¶ added in v0.2.1
func (tr *Trilu[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Trilu[T]) Forward ¶ added in v0.2.1
func (tr *Trilu[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Trilu[T]) OutputShape ¶ added in v0.2.1
func (*Trilu[T]) Parameters ¶ added in v0.2.1
type Unsqueeze ¶ added in v0.2.0
Unsqueeze is a layer that adds dimensions of size 1 to a tensor at specified axes.
func NewUnsqueeze ¶ added in v0.2.0
NewUnsqueeze creates a new Unsqueeze layer.
func (*Unsqueeze[T]) Attributes ¶ added in v0.2.0
Attributes returns the attributes of the Unsqueeze layer.
func (*Unsqueeze[T]) Backward ¶ added in v0.2.0
func (u *Unsqueeze[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes the gradients for the Unsqueeze layer.
func (*Unsqueeze[T]) Forward ¶ added in v0.2.0
func (u *Unsqueeze[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the unsqueeze operation by reshaping the input tensor.
func (*Unsqueeze[T]) OpType ¶ added in v0.2.0
OpType returns the operation type of the Unsqueeze layer.
func (*Unsqueeze[T]) OutputShape ¶ added in v0.2.0
OutputShape returns the output shape of the Unsqueeze layer.
func (*Unsqueeze[T]) Parameters ¶ added in v0.2.0
Parameters returns no trainable parameters for the Unsqueeze layer.
type VariableSelection ¶ added in v0.2.1
VariableSelection implements per-sample soft feature gating. Given input [batch, num_features]:
hidden = GELU(input @ W1 + b1) [batch, hidden_dim] logits = hidden @ W2 + b2 [batch, num_features] weights = Softmax(logits, axis=1) [batch, num_features] output = input * weights * num_features [batch, num_features]
The rescaling by num_features preserves expected magnitude.
func NewVariableSelection ¶ added in v0.2.1
func NewVariableSelection[T tensor.Numeric]( name string, engine compute.Engine[T], ops numeric.Arithmetic[T], numFeatures, hiddenDim int, ) (*VariableSelection[T], error)
NewVariableSelection creates a new VariableSelection layer.
func (*VariableSelection[T]) Attributes ¶ added in v0.2.1
func (v *VariableSelection[T]) Attributes() map[string]interface{}
Attributes returns the attributes of the layer.
func (*VariableSelection[T]) Backward ¶ added in v0.2.1
func (v *VariableSelection[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
Backward computes gradients for VariableSelection.
func (*VariableSelection[T]) Forward ¶ added in v0.2.1
func (v *VariableSelection[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes per-sample feature gating.
func (*VariableSelection[T]) OpType ¶ added in v0.2.1
func (v *VariableSelection[T]) OpType() string
OpType returns the operation type of the layer.
func (*VariableSelection[T]) OutputShape ¶ added in v0.2.1
func (v *VariableSelection[T]) OutputShape() []int
OutputShape returns the output shape of the layer.
func (*VariableSelection[T]) Parameters ¶ added in v0.2.1
func (v *VariableSelection[T]) Parameters() []*graph.Parameter[T]
Parameters returns the parameters of the layer.
type Where ¶ added in v0.2.1
Where selects elements from two tensors based on a condition tensor. Output[i] = x[i] if condition[i] != 0, else y[i].
func (*Where[T]) Attributes ¶ added in v0.2.1
func (*Where[T]) Backward ¶ added in v0.2.1
func (w *Where[T]) Backward(_ context.Context, _ types.BackwardMode, _ *tensor.TensorNumeric[T], _ ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)
func (*Where[T]) Forward ¶ added in v0.2.1
func (w *Where[T]) Forward(_ context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
func (*Where[T]) OutputShape ¶ added in v0.2.1
func (*Where[T]) Parameters ¶ added in v0.2.1
Source Files
¶
- add.go
- bias.go
- cast.go
- cast_registry.go
- concat.go
- concat_registry.go
- constant.go
- constantofshape.go
- conv1d.go
- conv2d.go
- cos.go
- dense.go
- div.go
- doc.go
- equal.go
- expand.go
- ffn.go
- film.go
- gemm.go
- global_avg_pool.go
- greater.go
- lessorequal.go
- linear.go
- lm_head.go
- matmul.go
- matmul_nbits.go
- matmul_nbits_nocuda.go
- matmul_registry.go
- max.go
- mod.go
- moe.go
- mul.go
- mul_registry.go
- neg.go
- or.go
- pad.go
- polynomial.go
- pow.go
- range_op.go
- reducemean.go
- registry.go
- reshape.go
- reshape_registry.go
- resize.go
- rotary_embedding.go
- rotary_embedding_registry.go
- scatternd.go
- seq_classification.go
- shape.go
- shape_registry.go
- sin.go
- slice.go
- spectral_fingerprint.go
- spectral_fingerprint_registry.go
- sqrt.go
- squeeze.go
- sub.go
- sub_registry.go
- temporal_conv_encoder.go
- tile.go
- topk.go
- trilu.go
- unsqueeze.go
- unsqueeze_registry.go
- variable_selection.go
- where.go