viva_tensor/axis

Axis - Named axis types for semantic tensor dimensions

Gives meaning to tensor dimensions: Batch, Seq, Feature, etc.

Types

Named axis - gives semantic meaning to a dimension

pub type Axis {
  Batch
  Seq
  Feature
  Height
  Width
  Channel
  Input
  Output
  Head
  Embed
  Named(String)
  Anon
}

Constructors

  • Batch

    Batch dimension (samples in mini-batch)

  • Seq

    Sequence/time dimension (for RNNs, transformers)

  • Feature

    Feature/channel dimension

  • Height

    Spatial height

  • Width

    Spatial width

  • Channel

    Channel dimension (for images)

  • Input

    Input dimension (for weight matrices)

  • Output

    Output dimension (for weight matrices)

  • Head

    Head dimension (for multi-head attention)

  • Embed

    Embedding dimension

  • Named(String)

    Custom named axis

  • Anon

    Anonymous axis (unnamed, referenced by position)

Axis with its size

pub type AxisSpec {
  AxisSpec(name: Axis, size: Int)
}

Constructors

  • AxisSpec(name: Axis, size: Int)

Values

pub fn axis(name: Axis, size: Int) -> AxisSpec

Create axis spec

pub fn batch(size: Int) -> AxisSpec

Batch dimension

pub fn channel(size: Int) -> AxisSpec

Channel dimension

pub fn embed(size: Int) -> AxisSpec

Embed dimension

pub fn equals(a: Axis, b: Axis) -> Bool

Check if two axes are equal

pub fn feature(size: Int) -> AxisSpec

Feature dimension

pub fn head(size: Int) -> AxisSpec

Head dimension

pub fn height(size: Int) -> AxisSpec

Height dimension

pub fn input(size: Int) -> AxisSpec

Input dimension

pub fn named(name: String, size: Int) -> AxisSpec

Custom named dimension

pub fn output(size: Int) -> AxisSpec

Output dimension

pub fn seq(size: Int) -> AxisSpec

Sequence dimension

pub fn specs_equal(a: List(AxisSpec), b: List(AxisSpec)) -> Bool

Check if two axis spec lists are equal

pub fn to_string(a: Axis) -> String

Get human-readable axis name

pub fn width(size: Int) -> AxisSpec

Width dimension

Search Document