[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:50:12 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> {
----------------
svkeerthy wrote:

I wanted to model `Embedding` as a specialization of vector and preferred inheriting from std::vector<double> primarily for the convenience; It allows us to directly use the existing interfaces (like iterators, size(), empty(), push_back(), etc.) without needing to write explicit wrapper methods. I found some instances in LLVM inheriting std containers. Please let me know what do you think. 


https://github.com/llvm/llvm-project/pull/143197


More information about the llvm-commits mailing list