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::stringOp name used in error messages (e.g.
"matmul").Examples
`
Validator::pair(a, b, "matmul")
.both_non_null()
.same_dtype()
.same_device();
`Constructors
1Constructs 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::stringOp name used as the prefix in error messages.
Methods
4Asserts that both operand pointers are non-null.
Returns
Pair&*this.
Raises
LucidErrorIf either
a_ or b_ is null.Asserts that both operands reside on the same device.
Implicitly calls both_non_null first.
Returns
Pair&*this.
Raises
LucidErrorIf either operand is null.
DeviceMismatchIf
a_->device() != b_->device().Asserts that both operands share the same dtype.
Implicitly calls both_non_null first.
Returns
Pair&*this.
Raises
LucidErrorIf either operand is null.
DtypeMismatchIf
a_->dtype() != b_->dtype().Asserts that both operands share the same shape.
Implicitly calls both_non_null first.
Returns
Pair&*this.
Raises
LucidErrorIf either operand is null.
ShapeMismatchIf
a_->shape() != b_->shape().