Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ArrayRef in AxisInfo constructors #2720

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions include/triton/Analysis/AxisInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ class AxisInfo {
public:
AxisInfo() : AxisInfo({}, {}, {}) {}

AxisInfo(DimVectorT contiguity, DimVectorT divisibility, DimVectorT constancy)
AxisInfo(ArrayRef<int64_t> contiguity, ArrayRef<int64_t> divisibility,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common file so changes should be done upsrteam.

ArrayRef<int64_t> constancy)
: AxisInfo(contiguity, divisibility, constancy, std::nullopt) {}

AxisInfo(DimVectorT contiguity, DimVectorT divisibility, DimVectorT constancy,
std::optional<int64_t> constantValue)
AxisInfo(ArrayRef<int64_t> contiguity, ArrayRef<int64_t> divisibility,
ArrayRef<int64_t> constancy, std::optional<int64_t> constantValue)
: contiguity(contiguity), divisibility(divisibility),
constancy(constancy), constantValue(constantValue) {
assert(divisibility.size() == contiguity.size());
Expand Down
34 changes: 12 additions & 22 deletions third_party/intel/lib/Analysis/AxisInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ class BinaryOpVisitorImpl : public AxisInfoVisitorImpl<OpTy> {
divisibility.push_back(getDivisibility(op, lhsInfo, rhsInfo, d));
}
}
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy), constantValue);
return AxisInfo(contiguity, divisibility, constancy, constantValue);
}

protected:
Expand Down Expand Up @@ -544,8 +543,7 @@ class SplatOpAxisInfoVisitor final
divisibility.push_back(opInfo.getDivisibility(0));
constancy.push_back(retTy.getShape()[d]);
}
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy),
return AxisInfo(contiguity, divisibility, constancy,
operands[0]->getValue().getConstantValue());
}
};
Expand Down Expand Up @@ -576,8 +574,7 @@ class LoadOpAxisInfoVisitor final : public AxisInfoVisitorImpl<triton::LoadOp> {
maskInfo.has_value() ? maskInfo->getConstancy(d) : 0));
}

return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy));
return AxisInfo(contiguity, divisibility, constancy);
}
};

Expand Down Expand Up @@ -611,8 +608,7 @@ class ExpandDimsOpAxisInfoVisitor final
contiguity.insert(contiguity.begin() + op.getAxis(), 1);
divisibility.insert(divisibility.begin() + op.getAxis(), newDivisibility);
constancy.insert(constancy.begin() + op.getAxis(), 1);
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy),
return AxisInfo(contiguity, divisibility, constancy,
operands[0]->getValue().getConstantValue());
}
};
Expand Down Expand Up @@ -641,8 +637,7 @@ class BroadcastOpAxisInfoVisitor final
constancy.push_back(opShape[d] == 1 ? retShape[d]
: opInfo.getConstancy(d));
}
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy),
return AxisInfo(contiguity, divisibility, constancy,
operands[0]->getValue().getConstantValue());
}
};
Expand Down Expand Up @@ -717,8 +712,7 @@ class CmpOpAxisInfoVisitor final : public AxisInfoVisitorImpl<OpTy> {
contiguity.push_back(1);
}

return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy), constantValue);
return AxisInfo(contiguity, divisibility, constancy, constantValue);
}

private:
Expand Down Expand Up @@ -846,8 +840,7 @@ class SelectOpAxisInfoVisitor final : public AxisInfoVisitorImpl<OpTy> {
constantValue = lhsInfo.getConstantValue();
}

return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy), constantValue);
return AxisInfo(contiguity, divisibility, constancy, constantValue);
}
};

Expand Down Expand Up @@ -1000,8 +993,7 @@ class MaxMinOpAxisInfoVisitor final : public AxisInfoVisitorImpl<OpTy> {
contiguity.push_back(
std::min(lhsInfo.getContiguity(d), rhsInfo.getContiguity(d)));
}
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy), std::nullopt);
return AxisInfo(contiguity, divisibility, constancy, std::nullopt);
}
}
};
Expand Down Expand Up @@ -1046,8 +1038,7 @@ class MakeTensorPtrOpAxisInfoVisitor final
constancy.push_back(1);
}

auto axisInfo = AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy));
auto axisInfo = AxisInfo(contiguity, divisibility, constancy);

LLVM_DEBUG({
std::string axisStr;
Expand Down Expand Up @@ -1152,8 +1143,8 @@ LogicalResult AxisInfoAnalysis::visitOperation(
auto vals = cast<DenseElementsAttr>(attr).getValues<int>();
newConstancy = AxisInfo::DimVectorT(vals.begin(), vals.end());
}
curr = AxisInfo(std::move(newContiguity), std::move(newDivisibility),
std::move(newConstancy), curr.getConstantValue());
curr = AxisInfo(newContiguity, newDivisibility, newConstancy,
curr.getConstantValue());
// join all lattice elements
for (auto *result : results)
propagateIfChanged(result, result->join(curr));
Expand All @@ -1173,8 +1164,7 @@ void AxisInfoAnalysis::visitForOpInductionVar(
AxisInfo::DimVectorT knownConstancy(1, 1);
knownDivisibility[0] = gcd(lb.getDivisibility(0), step.getDivisibility(0));
auto inductionVar =
AxisInfo(std::move(knownContiguity), std::move(knownDivisibility),
std::move(knownConstancy));
AxisInfo(knownContiguity, knownDivisibility, knownConstancy);
(void)argLattices[0]->join(inductionVar);
}

Expand Down