[llvm] [IR2Vec] Adding unit tests (PR #141873)
S. VenkataKeerthy via llvm-commits
llvm-commits at lists.llvm.org
Thu May 29 10:59:46 PDT 2025
================
@@ -0,0 +1,254 @@
+//===- IR2VecTest.cpp - Unit tests for IR2Vec -----------------------------==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/IR2Vec.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Type.h"
+#include "llvm/Support/Error.h"
+
+#include "gtest/gtest.h"
+#include <map>
+#include <vector>
+
+using namespace llvm;
+using namespace ir2vec;
+
+namespace {
+
+class TestableEmbedder : public Embedder {
+public:
+ TestableEmbedder(const Function &F, const Vocab &V, unsigned Dim)
+ : Embedder(F, V, Dim) {}
+ void computeEmbeddings() const override {}
+ using Embedder::lookupVocab;
+ static void addVectors(Embedding &Dst, const Embedding &Src) {
+ Embedder::addVectors(Dst, Src);
+ }
+ static void addScaledVector(Embedding &Dst, const Embedding &Src,
+ float Factor) {
+ Embedder::addScaledVector(Dst, Src, Factor);
+ }
+};
+
+class IR2VecTest : public ::testing::Test {
----------------
svkeerthy wrote:
Removed `IR2VecTest` and changed everything to `TEST`
https://github.com/llvm/llvm-project/pull/141873
More information about the llvm-commits
mailing list