Conversation
Contributor
Author
This was referenced Jun 20, 2025
approximatelyEquals() of Embedding
Member
|
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-mlgo Author: S. VenkataKeerthy (svkeerthy) ChangesIncrease the default tolerance for Full diff: https://github.com/llvm/llvm-project/pull/145117.diff 2 Files Affected:
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h
index 06312562060aa..480b834077b86 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -116,7 +116,7 @@ struct Embedding {
/// Returns true if the embedding is approximately equal to the RHS embedding
/// within the specified tolerance.
- bool approximatelyEquals(const Embedding &RHS, double Tolerance = 1e-6) const;
+ bool approximatelyEquals(const Embedding &RHS, double Tolerance = 1e-4) const;
void print(raw_ostream &OS) const;
};
diff --git a/llvm/unittests/Analysis/IR2VecTest.cpp b/llvm/unittests/Analysis/IR2VecTest.cpp
index 05af55b59323b..33ac16828eb6c 100644
--- a/llvm/unittests/Analysis/IR2VecTest.cpp
+++ b/llvm/unittests/Analysis/IR2VecTest.cpp
@@ -154,14 +154,14 @@ TEST(EmbeddingTest, ApproximatelyEqual) {
EXPECT_TRUE(E1.approximatelyEquals(E2)); // Diff = 1e-7
Embedding E3 = {1.00002, 2.00002, 3.00002}; // Diff = 2e-5
- EXPECT_FALSE(E1.approximatelyEquals(E3));
+ EXPECT_FALSE(E1.approximatelyEquals(E3, 1e-6));
EXPECT_TRUE(E1.approximatelyEquals(E3, 3e-5));
Embedding E_clearly_within = {1.0000005, 2.0000005, 3.0000005}; // Diff = 5e-7
EXPECT_TRUE(E1.approximatelyEquals(E_clearly_within));
Embedding E_clearly_outside = {1.00001, 2.00001, 3.00001}; // Diff = 1e-5
- EXPECT_FALSE(E1.approximatelyEquals(E_clearly_outside));
+ EXPECT_FALSE(E1.approximatelyEquals(E_clearly_outside, 1e-6));
Embedding E4 = {1.0, 2.0, 3.5}; // Large diff
EXPECT_FALSE(E1.approximatelyEquals(E4, 0.01));
|
mtrofin
reviewed
Jun 23, 2025
Member
mtrofin
left a comment
There was a problem hiding this comment.
why - as in, expected because upcoming change; or flakyness?
8b8932b to
29ebe35
Compare
bf89c59 to
0472d10
Compare
037cc63 to
cd4066f
Compare
0472d10 to
b2c203a
Compare
cd4066f to
f09b163
Compare
6cf6937 to
ec1d9d6
Compare
f09b163 to
f33b9e3
Compare
Base automatically changed from
users/svkeerthy/06-12-simplifying_creation_of_embedder
to
main
July 1, 2025 01:24
7516580 to
4a31512
Compare
Contributor
Author
|
Mostly due to flakyness. I found that some new tests added in the upcoming PR (#145119) were failing due to the precision issues. |
4a31512 to
6cbae82
Compare
Contributor
Author
Merge activity
|
This was referenced Jul 8, 2025
This was referenced Jul 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Increase the default tolerance for
approximatelyEqualsin IR2Vec's Embedding class from 1e-6 to 1e-4.(Tracking issue - #141817)