Skip to content

Commit 74de6b4

Browse files
authored
[Triton] Remove unused min/max_element helpers (NFC) (#5573)
These have been contributed upstream. Also switch a few `std::` usages to `llvm::`.
1 parent 110b66e commit 74de6b4

File tree

4 files changed

+6
-28
lines changed

4 files changed

+6
-28
lines changed

include/triton/Dialect/Triton/IR/Utility.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -167,27 +167,6 @@ template <typename VecT> bool isConsecutive(const VecT &vec) {
167167
return isConsecutive(ArrayRef(vec));
168168
}
169169

170-
// LLVM's STLExtras.h provides a bunch of functions that work over ranges, but
171-
// it's missing min/max_element until
172-
// https://github.com/llvm/llvm-project/commit/fab2bb8b makes it into Triton.
173-
// TODO(jlebar): Remove this once we have the LLVM helpers.
174-
template <typename R> auto min_element(R &&Range) {
175-
return std::min_element(llvm::adl_begin(Range), llvm::adl_end(Range));
176-
}
177-
template <typename R, typename Compare>
178-
auto min_element(R &&Range, Compare &&C) {
179-
return std::min_element(llvm::adl_begin(Range), llvm::adl_end(Range),
180-
std::forward<Compare>(C));
181-
}
182-
template <typename R> auto max_element(R &&Range) {
183-
return std::max_element(llvm::adl_begin(Range), llvm::adl_end(Range));
184-
}
185-
template <typename R, typename T, typename Compare>
186-
auto max_element(R &&Range, Compare &&C) {
187-
return std::max_element(llvm::adl_begin(Range), llvm::adl_end(Range),
188-
std::forward<Compare>(C));
189-
}
190-
191170
} // namespace triton
192171
} // namespace mlir
193172

lib/Dialect/TritonGPU/Transforms/LoopScheduling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ CoarseSchedule scheduleKeyOps(scf::ForOp forOp,
115115
}
116116

117117
auto stages = llvm::make_second_range(opToStage);
118-
int maxStage = *std::max_element(stages.begin(), stages.end());
118+
int maxStage = *llvm::max_element(stages);
119119
CoarseSchedule schedule(maxStage + 1);
120120
SmallVector<CoarseSchedule::Cluster> clusters(maxStage + 1);
121121
for (int i = 0; i <= maxStage; i++) {

lib/Dialect/TritonGPU/Transforms/Pipeliner/AssignLatencies.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ DenseMap<Operation *, int> assignLatencies(ModuleOp moduleOp,
257257

258258
// Calculate the stage distance between applicable loads.
259259
auto vals = llvm::make_second_range(loadOpToIndLevel);
260-
int maxIndirectionLevel =
261-
vals.empty() ? 0 : *std::max_element(vals.begin(), vals.end());
260+
int maxIndirectionLevel = vals.empty() ? 0 : *llvm::max_element(vals);
262261
unsigned loadLatency = (numStages - 1) / (maxIndirectionLevel + 1);
263262

264263
for (auto [loadOp, dist] : loadOpToIndLevel) {

lib/Dialect/TritonGPU/Transforms/ReorderInstructions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ class TritonGPUReorderInstructionsPass
5151
if (Operation *ancestor = op->getBlock()->findAncestorOpInBlock(*user))
5252
users.push_back(ancestor);
5353
}
54-
auto minOpIt = std::min_element(users.begin(), users.end(),
55-
[](mlir::Operation *a, mlir::Operation *b) {
56-
return a->isBeforeInBlock(b);
57-
});
54+
auto minOpIt =
55+
llvm::min_element(users, [](mlir::Operation *a, mlir::Operation *b) {
56+
return a->isBeforeInBlock(b);
57+
});
5858
return minOpIt != users.end() ? *minOpIt : nullptr;
5959
}
6060

0 commit comments

Comments
 (0)