Skip to content

[NFC][IR2Vec] Increasing tolerance in approximatelyEquals() of Embedding #145117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: users/svkeerthy/06-12-simplifying_creation_of_embedder
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/IR2Vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/Analysis/IR2VecTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading