[llvm] [IR2Vec] Exposing Embedding as an ADT wrapped around std::vector<double> (PR #143197)

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 9 11:11:47 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> {
----------------
mtrofin wrote:

which APIs do you actually need?

composition gives us more decoupling wrt underlying data structure. With an explicit constructor, you could control a to-from treatment of vectors (including llvm ADTs, potentially) as Embeddings. The delegation of curated APIs to the underlying data structure doesn't seem that big of a problem. 

ack that there are uses, not convinced they are necessarily an expression of best practices.

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


More information about the llvm-commits mailing list