[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 11:05:52 PDT 2025


================
@@ -55,6 +55,40 @@ static cl::opt<float> ArgWeight("ir2vec-arg-weight", cl::Optional,
 
 AnalysisKey IR2VecVocabAnalysis::Key;
 
+// ==----------------------------------------------------------------------===//
+// Embedding
+//===----------------------------------------------------------------------===//
+
+Embedding &Embedding::operator+=(const Embedding &RHS) {
+  assert(this->size() == RHS.size() && "Vectors must have the same dimension");
+  std::transform(this->begin(), this->end(), RHS.begin(), this->begin(),
----------------
svkeerthy wrote:

Yeah! And, `Embedding` is built on std::vector, so thought of just using std::transform.

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


More information about the llvm-commits mailing list