[llvm-branch-commits] [llvm] [IR2Vec] Add out-of-place arithmetic operators to Embedding class (PR #145118)
Mircea Trofin via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jul 1 10:54:04 PDT 2025
================
@@ -71,20 +71,43 @@ inline bool fromJSON(const llvm::json::Value &E, Embedding &Out,
// Embedding
//===----------------------------------------------------------------------===//
+Embedding Embedding::operator+(const Embedding &RHS) const {
+ assert(this->size() == RHS.size() && "Vectors must have the same dimension");
+ Embedding Result(*this);
+ std::transform(this->begin(), this->end(), RHS.begin(), Result.begin(),
+ std::plus<double>());
+ return Result;
+}
+
Embedding &Embedding::operator+=(const Embedding &RHS) {
assert(this->size() == RHS.size() && "Vectors must have the same dimension");
----------------
mtrofin wrote:
can you implement the <operator>= variants in terms of the <operator>?
https://github.com/llvm/llvm-project/pull/145118
More information about the llvm-branch-commits
mailing list