Skip to content
class

DtypeMismatch

extendsLucidError
DtypeMismatch

Thrown when a dtype mismatch prevents an operation from executing.

Both expected and got are stored as human-readable dtype names (e.g. "float32", "int8") rather than as raw enumerators so the exception can be formatted directly into what() without depending on the Dtype header. Mapped to lucid._C.engine.DtypeMismatch on the Python side.

Parameters

expectedstd::string
Required dtype name (or a "|"-separated set when multiple dtypes are accepted, as emitted by Validator::dtype_in).
gotstd::string
Dtype name that was actually supplied.
contextstd::string
Annotation produced by ErrorBuilder (op name and trace).

Attributes

expected_std::string
Stored copy of the required dtype name.
got_std::string
Stored copy of the offending dtype name.

Examples

```
ErrorBuilder("linear").dtype_mismatch(Dtype::F32, t.dtype(), "weight");
```

Constructors

1
ctor

DtypeMismatch

void DtypeMismatch(int expected, int got, int context)

Construct a DtypeMismatch with the expected vs actual dtype name and the op-level context annotation the call site captured. Stored verbatim in what() so callers see expected float32, got int8 style text.

Methods

2
fnconst

expected

→const std::string&
const int & expected()

Returns the dtype name that the operation required.

Returns

const std::string&

Stored expected argument; lifetime tied to *this.

fnconst

got

→const std::string&
const int & got()

Returns the dtype name that was actually supplied.

Returns

const std::string&

Stored got argument; lifetime tied to *this.