aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Analysis
diff options
context:
space:
mode:
authorS. VenkataKeerthy <31350914+svkeerthy@users.noreply.github.com>2025-05-29 15:29:55 -0700
committerGitHub <noreply@github.com>2025-05-29 15:29:55 -0700
commit494c82e709fa89110a3178bff1330a38f13f87be (patch)
tree5ad41983a6ce24428e22bc0ad49e20e9237950ef /llvm/unittests/Analysis
parent8a44cd74bdf8a650d85e144a640c595e1945e906 (diff)
downloadllvm-494c82e709fa89110a3178bff1330a38f13f87be.zip
llvm-494c82e709fa89110a3178bff1330a38f13f87be.tar.gz
llvm-494c82e709fa89110a3178bff1330a38f13f87be.tar.bz2
[IR2Vec] Support for lazy computation of BB Embeddings (#142033)
This PR exposes interfaces to compute embeddings at BB level. This would be necessary for delta patching the embeddings in MLInliner (#141836). (Tracking issue - #141817)
Diffstat (limited to 'llvm/unittests/Analysis')
-rw-r--r--llvm/unittests/Analysis/IR2VecTest.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/IR2VecTest.cpp b/llvm/unittests/Analysis/IR2VecTest.cpp
index 5fb4da9..0158038 100644
--- a/llvm/unittests/Analysis/IR2VecTest.cpp
+++ b/llvm/unittests/Analysis/IR2VecTest.cpp
@@ -31,6 +31,7 @@ public:
TestableEmbedder(const Function &F, const Vocab &V, unsigned Dim)
: Embedder(F, V, Dim) {}
void computeEmbeddings() const override {}
+ void computeEmbeddings(const BasicBlock &BB) const override {}
using Embedder::lookupVocab;
static void addVectors(Embedding &Dst, const Embedding &Src) {
Embedder::addVectors(Dst, Src);
@@ -229,6 +230,15 @@ TEST(IR2VecTest, GetBBVecMap) {
ElementsAre(DoubleNear(1.29, 1e-6), DoubleNear(2.31, 1e-6)));
}
+TEST(IR2VecTest, GetBBVector) {
+ GetterTestEnv Env;
+ const auto &BBVec = Env.Emb->getBBVector(*Env.BB);
+
+ EXPECT_EQ(BBVec.size(), 2u);
+ EXPECT_THAT(BBVec,
+ ElementsAre(DoubleNear(1.29, 1e-6), DoubleNear(2.31, 1e-6)));
+}
+
TEST(IR2VecTest, GetFunctionVector) {
GetterTestEnv Env;
const auto &FuncVec = Env.Emb->getFunctionVector();