Skip to content
class

Pair

Pair

Fluent precondition checker for a pair of tensors.

Mirrors Validator but for checks that compare two operands (same dtype, same device, same shape, etc.). Constructed via the static Validator::pair factory — direct construction exists only so the factory can return by value.

Attributes

a_const TensorImplPtr&
Reference to the first operand.
b_const TensorImplPtr&
Reference to the second operand.
op_std::string
Op name used in error messages (e.g. "matmul").

Examples

```
Validator::pair(a, b, "matmul")
    .both_non_null()
    .same_dtype()
    .same_device();
```

Constructors

1
ctor

Pair

void Pair(const int & a, const int & b, int op)

Constructs a Pair validator.

Parameters

aconst TensorImplPtr&
First operand. Reference retained; must outlive the chain.
bconst TensorImplPtr&
Second operand. Reference retained; must outlive the chain.
opstd::string
Op name used as the prefix in error messages.

Methods

4
fn

both_non_null

→Pair&
Pair & both_non_null()

Asserts that both operand pointers are non-null.

Returns

Pair&

*this.

Raises

LucidError
If either a_ or b_ is null.
fn

same_device

→Pair&
Pair & same_device()

Asserts that both operands reside on the same device.

Implicitly calls both_non_null first.

Returns

Pair&

*this.

Raises

LucidError
If either operand is null.
DeviceMismatch
If a_->device() != b_->device().
fn

same_dtype

→Pair&
Pair & same_dtype()

Asserts that both operands share the same dtype.

Implicitly calls both_non_null first.

Returns

Pair&

*this.

Raises

LucidError
If either operand is null.
DtypeMismatch
If a_->dtype() != b_->dtype().
fn

same_shape

→Pair&
Pair & same_shape()

Asserts that both operands share the same shape.

Implicitly calls both_non_null first.

Returns

Pair&

*this.

Raises

LucidError
If either operand is null.
ShapeMismatch
If a_->shape() != b_->shape().