SnakeBridge.Error.DtypeMismatchError exception (SnakeBridge v0.15.0)

Copy Markdown View Source

Error for tensor dtype incompatibilities.

Provides information about expected vs actual dtypes and suggestions for converting between types.

Examples

iex> error = %SnakeBridge.Error.DtypeMismatchError{
...>   expected: :float32,
...>   got: :float64,
...>   operation: :matmul,
...>   message: "Expected float32 but got float64"
...> }
iex> Exception.message(error)
"Dtype mismatch in matmul..."

Summary

Functions

Generates a suggestion for converting between dtypes.

Creates a DtypeMismatchError error with conversion suggestion.

Types

dtype()

@type dtype() :: :float16 | :float32 | :float64 | :int32 | :int64 | :bool | atom()

t()

@type t() :: %SnakeBridge.Error.DtypeMismatchError{
  __exception__: true,
  expected: dtype(),
  got: dtype(),
  message: String.t(),
  operation: atom() | nil,
  python_traceback: String.t() | nil,
  suggestion: String.t()
}

Functions

generate_suggestion(expected, got)

@spec generate_suggestion(dtype(), dtype()) :: String.t()

Generates a suggestion for converting between dtypes.

new(expected, got, opts \\ [])

@spec new(dtype(), dtype(), keyword()) :: t()

Creates a DtypeMismatchError error with conversion suggestion.