enhance(compiler): Add operators == and != for Integer / Tensor Lambda Arguments

This commit is contained in:
Andi Drebes
2022-09-20 15:56:26 +02:00
committed by rudy-6-4
parent ade86d935b
commit 9e24eccc9d

View File

@@ -65,6 +65,16 @@ public:
unsigned int getPrecision() const { return this->precision; }
BackingIntType getValue() const { return this->value; }
template <typename OtherBackingIntType>
bool operator==(const IntLambdaArgument<OtherBackingIntType> &other) const {
return getValue() == other.getValue();
}
template <typename OtherBackingIntType>
bool operator!=(const IntLambdaArgument<OtherBackingIntType> &other) const {
return !(*this == other);
}
static char ID;
protected:
@@ -177,6 +187,26 @@ public:
return this->value.data();
}
template <typename OtherScalarArgumentT>
bool
operator==(const TensorLambdaArgument<OtherScalarArgumentT> &other) const {
if (getDimensions() != other.getDimensions())
return false;
for (auto pair : llvm::zip(value, other.value)) {
if (std::get<0>(pair) != std::get<1>(pair))
return false;
}
return true;
}
template <typename OtherScalarArgumentT>
bool
operator!=(const TensorLambdaArgument<OtherScalarArgumentT> &other) const {
return !(*this == other);
}
static char ID;
protected: