Skip to content

Commit

Permalink
Refactor to use FactorAxesPair.assignTo api for assigning the picked …
Browse files Browse the repository at this point in the history
…axes to the picked factor.

PiperOrigin-RevId: 696809790
  • Loading branch information
Google-ML-Automation authored and copybara-github committed Nov 15, 2024
1 parent f5edbfa commit e3c5f3e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ struct FactorAxesPair {
bool operator==(const FactorAxesPair& rhs) const {
return factorIndex == rhs.factorIndex && axisRefs == rhs.axisRefs;
}

void assignTo(AxesPerFactor& axesPerFactor) {
axesPerFactor[factorIndex] = llvm::to_vector(axisRefs);
}
};

struct FactorAxesPairInfo : public llvm::DenseMapInfo<FactorAxesPair> {
Expand Down Expand Up @@ -251,8 +255,7 @@ AxesPerFactor findCommonAxesUsingMajorityVoteHeuristic(
// TODO(enver): Assign an axis to a factor immediately if the count is more
// than floor(n/2) where n is the number of tensors.
while (maxCount > 0) {
factorAxisRefs[bestFactorAxes.factorIndex] =
llvm::to_vector(bestFactorAxes.axisRefs);
bestFactorAxes.assignTo(factorAxisRefs);
// TODO(enver): Tie-breaking currently depends on the order of iteration.
// Consider some heuristic for breaking ties.
// Invalidate axes that overlaps with the picked one across all unseen
Expand Down

0 comments on commit e3c5f3e

Please sign in to comment.