[llvm] [IR2Vec] Exposing Embedding as an ADT wrapped around std::vector<double> (PR #143197)
S. VenkataKeerthy via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 9 10:54:28 PDT 2025
================
@@ -53,7 +53,24 @@ class raw_ostream;
enum class IR2VecKind { Symbolic };
namespace ir2vec {
-using Embedding = std::vector<double>;
+/// Embedding is a ADT that wraps std::vector<double>. It provides
+/// additional functionality for arithmetic and comparison operations.
+struct Embedding : public std::vector<double> {
+ using std::vector<double>::vector;
+
+ /// Arithmetic operators
+ Embedding &operator+=(const Embedding &RHS);
+ Embedding &operator-=(const Embedding &RHS);
+
+ /// Adds Src Embedding scaled by Factor with the called Embedding.
+ /// Called_Embedding += Src * Factor
+ void scaleAndAdd(const Embedding &Src, float Factor);
----------------
svkeerthy wrote:
Done
https://github.com/llvm/llvm-project/pull/143197
More information about the llvm-commits
mailing list