Snakepit.Error.Shape (Snakepit v0.8.7)

View Source

Shape error creation helpers.

Provides functions for creating detailed shape mismatch errors with automatic dimension detection and telemetry emission.

Summary

Functions

Creates a broadcast error.

Creates a dimension-specific mismatch error.

Creates a shape mismatch error.

Functions

broadcast_error(shape1, shape2, operation)

@spec broadcast_error([integer()], [integer()], String.t()) ::
  Snakepit.Error.ShapeMismatch.t()

Creates a broadcast error.

Use when shapes cannot be broadcast together.

dimension_mismatch(dimension, expected_dim, got_dim, operation)

@spec dimension_mismatch(non_neg_integer(), integer(), integer(), String.t()) ::
  Snakepit.Error.ShapeMismatch.t()

Creates a dimension-specific mismatch error.

Use when you know exactly which dimension has the mismatch.

shape_mismatch(expected, got, operation)

@spec shape_mismatch([integer()], [integer()], String.t()) ::
  Snakepit.Error.ShapeMismatch.t()

Creates a shape mismatch error.

Automatically detects which dimension differs and emits telemetry.

Examples

error = Shape.shape_mismatch([3, 224, 224], [3, 256, 256], "conv2d")