Skip to content

Commit bf89c59

Browse files
committed
Increasing tolerance in ApproximatelyEquals
1 parent 29ebe35 commit bf89c59

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/include/llvm/Analysis/IR2Vec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct Embedding {
116116

117117
/// Returns true if the embedding is approximately equal to the RHS embedding
118118
/// within the specified tolerance.
119-
bool approximatelyEquals(const Embedding &RHS, double Tolerance = 1e-6) const;
119+
bool approximatelyEquals(const Embedding &RHS, double Tolerance = 1e-4) const;
120120

121121
void print(raw_ostream &OS) const;
122122
};

llvm/unittests/Analysis/IR2VecTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ TEST(EmbeddingTest, ApproximatelyEqual) {
154154
EXPECT_TRUE(E1.approximatelyEquals(E2)); // Diff = 1e-7
155155

156156
Embedding E3 = {1.00002, 2.00002, 3.00002}; // Diff = 2e-5
157-
EXPECT_FALSE(E1.approximatelyEquals(E3));
157+
EXPECT_FALSE(E1.approximatelyEquals(E3, 1e-6));
158158
EXPECT_TRUE(E1.approximatelyEquals(E3, 3e-5));
159159

160160
Embedding E_clearly_within = {1.0000005, 2.0000005, 3.0000005}; // Diff = 5e-7
161161
EXPECT_TRUE(E1.approximatelyEquals(E_clearly_within));
162162

163163
Embedding E_clearly_outside = {1.00001, 2.00001, 3.00001}; // Diff = 1e-5
164-
EXPECT_FALSE(E1.approximatelyEquals(E_clearly_outside));
164+
EXPECT_FALSE(E1.approximatelyEquals(E_clearly_outside, 1e-6));
165165

166166
Embedding E4 = {1.0, 2.0, 3.5}; // Large diff
167167
EXPECT_FALSE(E1.approximatelyEquals(E4, 0.01));

0 commit comments

Comments
 (0)