Skip to content
class

DeviceMismatch

extendsLucidError
DeviceMismatch

Thrown when tensors from different devices are combined incorrectly.

Raised, for example, when a CPU tensor is passed to an op that requires a GPU tensor (or vice-versa), or when two operands disagree on their device placement. Mapped to lucid._C.engine.DeviceMismatch on the Python side.

Parameters

expectedstd::string
Device name the operation required (e.g. "cpu" or "metal:0").
gotstd::string
Device name of the offending tensor.
contextstd::string
Annotation produced by ErrorBuilder.

Attributes

expected_std::string
Stored copy of the required device label.
got_std::string
Stored copy of the offending device label.

Examples

```
ErrorBuilder("matmul").device_mismatch(a.device(), b.device());
```

Constructors

1
ctor

DeviceMismatch

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

Construct a DeviceMismatch with the expected vs actual device label and the op-level context annotation the call site captured. All three are formatted into the what() message.

Methods

2
fnconst

expected

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

Returns the device name the operation required.

Returns

const std::string&

Stored expected argument; lifetime tied to *this.

fnconst

got

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

Returns the device name that was actually supplied.

Returns

const std::string&

Stored got argument; lifetime tied to *this.