15 #ifndef MLIR_QUANTIZER_SUPPORT_RULES_H 16 #define MLIR_QUANTIZER_SUPPORT_RULES_H 18 #include "llvm/ADT/Optional.h" 66 template <
typename BinaryReducer>
69 using ValueTy =
typename BinaryReducer::ValueTy;
72 :
value(BinaryReducer::initialValue()),
73 salience(std::numeric_limits<int>::min()) {}
76 bool hasValue()
const {
return salience != std::numeric_limits<int>::min(); }
79 if (assertSalience > salience) {
82 salience = assertSalience;
84 }
else if (assertSalience < salience) {
89 ValueTy updatedValue = BinaryReducer::reduce(
value, assertValue);
112 return std::make_pair(std::numeric_limits<double>::infinity(),
113 -std::numeric_limits<double>::infinity());
116 return std::make_pair(std::min(lhs.first, rhs.first),
117 std::max(lhs.second, rhs.second));
123 template <
typename T>
127 if (std::numeric_limits<T>::has_infinity()) {
128 return std::numeric_limits<T>::infinity();
130 return std::numeric_limits<T>::max();
140 template <
typename T>
144 if (std::numeric_limits<T>::has_infinity()) {
145 return -std::numeric_limits<T>::infinity();
147 return std::numeric_limits<T>::min();
159 template <
typename T>
170 if (value && other.
value) {
171 return *value == *other.
value;
173 return !value && !other.
value;
191 template <
typename T>
200 #endif // MLIR_QUANTIZER_SUPPORT_RULES_H Definition: InferTypeOpInterface.cpp:20
bool modified(ModificationResult m)
Definition: Rules.h:52
BasePropagatedFact()
Definition: Rules.h:71
bool conflict
Definition: Rules.h:166
ModificationResult(ModificationEnum v)
Definition: Rules.h:30
typename ExpandingMinMaxReducer ::ValueTy ValueTy
Definition: Rules.h:69
llvm::Optional< T > value
Definition: Rules.h:165
static ValueTy reduce(ValueTy lhs, ValueTy rhs)
Definition: Rules.h:115
ModificationResult operator|=(ModificationResult other)
Definition: Rules.h:40
ModificationResult operator|(ModificationResult other)
Definition: Rules.h:32
T ValueTy
Definition: Rules.h:125
Typed indicator of whether a mutator produces a modification.
Definition: Rules.h:28
std::pair< double, double > ValueTy
Definition: Rules.h:110
ModificationResult assertValue(int assertSalience, ValueTy assertValue)
Definition: Rules.h:78
ModificationEnum
Definition: Rules.h:29
static ValueTy initialValue()
Definition: Rules.h:143
static ValueTy reduce(ValueTy lhs, ValueTy rhs)
Definition: Rules.h:133
int getSalience() const
Definition: Rules.h:75
bool operator!=(const ValueTy &other) const
Definition: Rules.h:176
int64_t mod(int64_t lhs, int64_t rhs)
Definition: MathExtras.h:41
A binary reducer that maximizes a numeric type.
Definition: Rules.h:141
ValueTy getValue() const
Definition: Rules.h:77
static ValueTy initialValue()
Definition: Rules.h:178
static ValueTy reduce(ValueTy lhs, ValueTy rhs)
Definition: Rules.h:150
A binary reducer that minimizing a numeric type.
Definition: Rules.h:124
enum mlir::quantizer::ModificationResult::ModificationEnum value
ValueTy()
Definition: Rules.h:162
bool operator==(const ValueTy &other) const
Definition: Rules.h:167
static ValueTy initialValue()
Definition: Rules.h:126
bool hasValue() const
Definition: Rules.h:76
static ValueTy reduce(ValueTy lhs, ValueTy rhs)
Definition: Rules.h:179
ModificationResult modify(bool isModified=true)
Definition: Rules.h:47
ValueTy(T value)
Definition: Rules.h:163
ModificationResult mergeFrom(const ThisTy &other)
Definition: Rules.h:94
T ValueTy
Definition: Rules.h:142
ValueTy(T value, bool conflict)
Definition: Rules.h:164
static ValueTy initialValue()
Definition: Rules.h:111