nn

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dense

func Dense(x, weight, bias *Node, activation ...activations.Type) *Node

Dense performs a dense (linear) transformation with optional activation:

y = activation(x @ weight + bias)

weight has shape [in_features, out_features...]. bias is optional (nil means no bias). x's last axis contracts with weight's first axis.

activation is optional; if omitted or activations.TypeNone, no activation is applied.

If the backend supports fused Dense, the optimized native implementation is used; otherwise the operation is decomposed into primitives. Fallback is handled automatically via InternalFusedOpCaller.

func LayerNorm

func LayerNorm(x *Node, axes []int, epsilon float64, gamma, beta, mask *Node) *Node

LayerNorm performs layer normalization on x over the given axes with the specified epsilon. gamma and beta are optional (nil means skip scale/shift). mask is optional (nil means no masking). When a mask is provided, the decomposed path is always used (fused ops don't support masking).

If the backend supports fused LayerNorm, the optimized native implementation is used; otherwise the operation is decomposed into primitives. Fallback is handled automatically via InternalFusedOpCaller.

func QuantizedDense

func QuantizedDense(x, weights *Node, quant *Quantization, bias *Node,
	activation ...activations.Type) *Node

QuantizedDense performs a quantized dense (linear) transformation with optional activation:

y = activation(x @ dequant(weights, quant) + bias)

The weights are dequantized on the fly using the quantization metadata, then multiplied with x.

Parameters:

  • x: [batch..., K] float32 input activations.
  • weights: [K, N] with dtype reflecting storage type (e.g. Int4, Int8). For sub-byte types, Bitcast packed uint8 data to the correct dtype first.
  • quant: quantization metadata (scheme, scale, zeroPoint, blockAxis, blockSize).
  • bias: [N] float32 (nil means no bias).
  • activation: optional; if omitted or activations.TypeNone, no activation is applied.

If the backend supports fused QuantizedDense, the optimized native implementation is used; otherwise the operation is decomposed into primitives. Fallback is handled automatically via InternalFusedOpCaller.

Types

This section is empty.

Jump to

Keyboard shortcuts

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