Error for tensor shape incompatibilities.
This error provides detailed information about shape mismatches including the operation that failed, the shapes involved, and actionable suggestions.
Examples
iex> error = %SnakeBridge.Error.ShapeMismatchError{
...> operation: :matmul,
...> shape_a: [3, 4],
...> shape_b: [2, 5],
...> message: "Cannot multiply matrices with incompatible shapes",
...> suggestion: "A has 4 columns but B has 2 rows. Transpose B."
...> }
iex> Exception.message(error)
"Shape mismatch in matmul..."
Summary
Functions
Generates a suggestion based on the operation and shapes.
Creates a ShapeMismatchError error from context.
Types
@type t() :: %SnakeBridge.Error.ShapeMismatchError{ __exception__: true, expected: String.t() | nil, got: String.t() | nil, message: String.t(), operation: atom(), python_traceback: String.t() | nil, shape_a: [non_neg_integer()] | nil, shape_b: [non_neg_integer()] | nil, suggestion: String.t() }
Functions
@spec generate_suggestion( atom(), [non_neg_integer()] | nil, [non_neg_integer()] | nil ) :: String.t()
Generates a suggestion based on the operation and shapes.
Creates a ShapeMismatchError error from context.