Skip to content

[mlir] Use range constructors of *Set (NFC) #137563

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

Merged
merged 1 commit into from
Apr 28, 2025
Merged
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
3 changes: 1 addition & 2 deletions mlir/lib/Analysis/SliceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ static bool dependsOnCarriedVals(Value value,

// Check that none of the operands of the operations in the backward slice are
// loop iteration arguments, and neither is the value itself.
SmallPtrSet<Value, 8> iterCarriedValSet(iterCarriedArgs.begin(),
iterCarriedArgs.end());
SmallPtrSet<Value, 8> iterCarriedValSet(llvm::from_range, iterCarriedArgs);
if (iterCarriedValSet.contains(value))
return true;

Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ outlineExecuteOp(SymbolTable &symbolTable, ExecuteOp execute) {
cloneConstantsIntoTheRegion(execute.getBodyRegion());

// Collect all outlined function inputs.
SetVector<mlir::Value> functionInputs(execute.getDependencies().begin(),
execute.getDependencies().end());
SetVector<mlir::Value> functionInputs(llvm::from_range,
execute.getDependencies());
functionInputs.insert_range(execute.getBodyOperands());
getUsedValuesDefinedAbove(execute.getBodyRegion(), functionInputs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ struct CondBranchOpInterface
// We specifically need to update the ownerships of values that are retained
// in both dealloc operations again to get a combined 'Unique' ownership
// instead of an 'Unknown' ownership.
SmallPtrSet<Value, 16> thenValues(thenTakenDeallocOp.getRetained().begin(),
thenTakenDeallocOp.getRetained().end());
SmallPtrSet<Value, 16> thenValues(llvm::from_range,
thenTakenDeallocOp.getRetained());
SetVector<Value> commonValues;
for (Value val : elseTakenDeallocOp.getRetained()) {
if (thenValues.contains(val))
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ gpu::GPUFuncOp mlir::outlineKernelFunc(gpu::LaunchOp launchOp,
llvm::SmallVectorImpl<Value> &operands) {
DenseSet<Value> inputOperandSet;
inputOperandSet.insert_range(operands);
SetVector<Value> operandSet(operands.begin(), operands.end());
SetVector<Value> operandSet(llvm::from_range, operands);
auto funcOp = outlineKernelFuncImpl(launchOp, kernelFnName, operandSet);
for (auto operand : operandSet) {
if (!inputOperandSet.count(operand))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,7 @@ transform::FuseIntoContainingOp::apply(transform::TransformRewriter &rewriter,

// Helper function to find the next producer that should be fused. Take any
// producer that has a use inside the containing op.
SetVector<Operation *> remainingProducers(producerOps.begin(),
producerOps.end());
SetVector<Operation *> remainingProducers(llvm::from_range, producerOps);
auto getNextProducer = [&]() -> FailureOr<Operation *> {
for (const auto &it : enumerate(remainingProducers)) {
Operation *producerOp = it.value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,13 +766,12 @@ bubbleUpPackOpThroughExpandShape(tensor::ExpandShapeOp expandOp,
SmallVector<ReassociationIndices, 4> reassoc =
expandOp.getReassociationIndices();
ArrayRef<int64_t> packInnerDims = packOp.getInnerDimsPos();
llvm::SetVector<int64_t> packDimsPos(packInnerDims.begin(),
packInnerDims.end());
llvm::SetVector<int64_t> packDimsPos(llvm::from_range, packInnerDims);

for (auto [idx, indices] : llvm::enumerate(reassoc)) {
// For each expand_shape reassociation, figure out which dimensions get
// packed if any.
llvm::SetVector<int64_t> expandDimPos(indices.begin(), indices.end());
llvm::SetVector<int64_t> expandDimPos(llvm::from_range, indices);
llvm::SetVector<int64_t> packedDims =
llvm::set_intersection(packDimsPos, expandDimPos);

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ SmallVector<spirv::Capability, 0>
spirv::getRecursiveImpliedCapabilities(spirv::Capability cap) {
ArrayRef<spirv::Capability> directCaps = getDirectImpliedCapabilities(cap);
SetVector<spirv::Capability, SmallVector<spirv::Capability, 0>> allCaps(
directCaps.begin(), directCaps.end());
llvm::from_range, directCaps);

// TODO: This is insufficient; find a better way to handle this
// (e.g., using static lists) if this turns out to be a bottleneck.
Expand Down
6 changes: 3 additions & 3 deletions mlir/lib/Dialect/Transform/IR/TransformOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ transform::MergeHandlesOp::apply(transform::TransformRewriter &rewriter,
return DiagnosedSilenceableFailure::success();
}

SetVector<Operation *> uniqued(operations.begin(), operations.end());
SetVector<Operation *> uniqued(llvm::from_range, operations);
results.set(llvm::cast<OpResult>(getResult()), uniqued.getArrayRef());
return DiagnosedSilenceableFailure::success();
}
Expand All @@ -2087,7 +2087,7 @@ transform::MergeHandlesOp::apply(transform::TransformRewriter &rewriter,
return DiagnosedSilenceableFailure::success();
}

SetVector<Attribute> uniqued(attrs.begin(), attrs.end());
SetVector<Attribute> uniqued(llvm::from_range, attrs);
results.setParams(cast<OpResult>(getResult()), uniqued.getArrayRef());
return DiagnosedSilenceableFailure::success();
}
Expand All @@ -2103,7 +2103,7 @@ transform::MergeHandlesOp::apply(transform::TransformRewriter &rewriter,
return DiagnosedSilenceableFailure::success();
}

SetVector<Value> uniqued(payloadValues.begin(), payloadValues.end());
SetVector<Value> uniqued(llvm::from_range, payloadValues);
results.setValues(cast<OpResult>(getResult()), uniqued.getArrayRef());
return DiagnosedSilenceableFailure::success();
}
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Transforms/Utils/DialectConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2747,8 +2747,7 @@ LogicalResult OperationConverter::convertOperations(ArrayRef<Operation *> ops) {
void mlir::reconcileUnrealizedCasts(
ArrayRef<UnrealizedConversionCastOp> castOps,
SmallVectorImpl<UnrealizedConversionCastOp> *remainingCastOps) {
SetVector<UnrealizedConversionCastOp> worklist(castOps.begin(),
castOps.end());
SetVector<UnrealizedConversionCastOp> worklist(llvm::from_range, castOps);
// This set is maintained only if `remainingCastOps` is provided.
DenseSet<Operation *> erasedOps;

Expand Down
Loading