Skip to content

Commit 21e2481

Browse files
committed
Use llvm::filter_to_vector. NFC.
I recently added this to SmallVectorExtras: llvm/llvm-project#117460. Signed-off-by: Jakub Kuderski <[email protected]>
1 parent 53e9601 commit 21e2481

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,17 @@ using mlir::transform::NamedSequenceOp;
3535
static SmallVector<ModuleOp>
3636
findNestedModulesWithNamedSequences(ModuleOp module) {
3737
Block *body = module.getBody();
38-
return llvm::to_vector(
39-
llvm::make_filter_range(body->getOps<ModuleOp>(), [](ModuleOp op) {
40-
return op.getSymName().has_value() &&
41-
op->hasAttr(
42-
transform::TransformDialect::kWithNamedSequenceAttrName);
43-
}));
38+
return llvm::filter_to_vector(body->getOps<ModuleOp>(), [](ModuleOp op) {
39+
return op.getSymName().has_value() &&
40+
op->hasAttr(transform::TransformDialect::kWithNamedSequenceAttrName);
41+
});
4442
}
4543

4644
static SmallVector<NamedSequenceOp> findTuningSpecs(ModuleOp module) {
4745
Block *body = module.getBody();
48-
return llvm::to_vector(llvm::make_filter_range(
46+
return llvm::filter_to_vector(
4947
body->getOps<NamedSequenceOp>(),
50-
[](NamedSequenceOp op) { return op->hasAttr(kTuningSpecAttrName); }));
48+
[](NamedSequenceOp op) { return op->hasAttr(kTuningSpecAttrName); });
5149
}
5250

5351
static LogicalResult validateTuningSpec(NamedSequenceOp op) {

compiler/src/iree/compiler/Codegen/Common/ReconcileTranslationInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ static LogicalResult resolveWorkgroupForAll(RewriterBase &rewriter,
265265
}
266266

267267
auto forAllOps = body.getOps<scf::ForallOp>();
268-
SmallVector<scf::ForallOp> workgroupForAllOps = llvm::to_vector(
269-
llvm::make_filter_range(forAllOps, [&](scf::ForallOp forAllOp) {
268+
SmallVector<scf::ForallOp> workgroupForAllOps =
269+
llvm::filter_to_vector(forAllOps, [&](scf::ForallOp forAllOp) {
270270
auto mapping = forAllOp.getMapping();
271271
if (!mapping) {
272272
return false;
@@ -277,7 +277,7 @@ static LogicalResult resolveWorkgroupForAll(RewriterBase &rewriter,
277277
return false;
278278
}
279279
return true;
280-
}));
280+
});
281281

282282
if (workgroupForAllOps.empty()) {
283283
// If there are no workgroup distribution loops, set the default

compiler/src/iree/compiler/Codegen/Interfaces/PartitionableLoopsInterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "iree/compiler/Dialect/LinalgExt/IR/LinalgExtDialect.h"
1212
#include "iree/compiler/Dialect/LinalgExt/IR/LinalgExtOps.h"
1313
#include "llvm/ADT/SmallVector.h"
14+
#include "llvm/ADT/SmallVectorExtras.h"
1415
#include "mlir/Dialect/Linalg/IR/Linalg.h"
1516
#include "mlir/Dialect/Tensor/IR/Tensor.h"
1617
#include "mlir/IR/BuiltinTypes.h"
@@ -26,10 +27,9 @@ namespace mlir::iree_compiler {
2627
static llvm::SmallVector<unsigned>
2728
pruneUnitTripParallelLoops(llvm::ArrayRef<unsigned> parallelLoops,
2829
llvm::ArrayRef<int64_t> loopRanges) {
29-
return llvm::to_vector(
30-
llvm::make_filter_range(parallelLoops, [&loopRanges](unsigned loopDim) {
31-
return loopRanges[loopDim] != 1;
32-
}));
30+
return llvm::filter_to_vector(parallelLoops, [&loopRanges](unsigned loopDim) {
31+
return loopRanges[loopDim] != 1;
32+
});
3333
}
3434

3535
/// Returns the partitionable loops for all Linalg ops.

compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "iree/compiler/Dialect/HAL/IR/HALTypes.h"
1818
#include "iree/compiler/Dialect/LinalgExt/IR/LinalgExtOps.h"
1919
#include "iree/compiler/Dialect/LinalgExt/Utils/IndexingUtils.h"
20+
#include "llvm/ADT/SmallVectorExtras.h"
2021
#include "llvm/ADT/TypeSwitch.h"
2122
#include "llvm/Support/CommandLine.h"
2223
#include "llvm/Support/Debug.h"
@@ -2784,10 +2785,10 @@ adjustTileSizesForUnPackOp(mlir::FunctionOpInterface entryPointFn,
27842785
// Remove the "enable_loop_peeling" attr from pipelineConfig
27852786
auto enableLoopPeelingAttrName =
27862787
getEnableLoopPeelingAttrName(rootOp->getContext());
2787-
auto newPipelineConfigEntries = llvm::to_vector(llvm::make_filter_range(
2788+
auto newPipelineConfigEntries = llvm::filter_to_vector(
27882789
pipelineConfig.getValue(), [&](NamedAttribute entry) {
27892790
return entry.getName() != enableLoopPeelingAttrName;
2790-
}));
2791+
});
27912792

27922793
pipelineConfig =
27932794
DictionaryAttr::get(rootOp->getContext(), newPipelineConfigEntries);

compiler/src/iree/compiler/Codegen/SPIRV/SPIRVMaterializeExecutableConditions.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "iree/compiler/Codegen/SPIRV/Utils.h"
99
#include "iree/compiler/Dialect/HAL/IR/HALOps.h"
1010
#include "llvm/ADT/STLExtras.h"
11+
#include "llvm/ADT/SmallVectorExtras.h"
1112
#include "mlir/Dialect/Arith/IR/Arith.h"
1213
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
1314
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
@@ -322,10 +323,10 @@ struct SPIRVMaterializeExecutableConditionsPass final
322323

323324
// Drop the fine-grained SPIR-V target and add the course-grained device
324325
// queries as a list.
325-
auto dictKeyValues = llvm::to_vector(llvm::make_filter_range(
326+
auto dictKeyValues = llvm::filter_to_vector(
326327
configuration.getValue(), [](NamedAttribute attr) {
327328
return attr.getName() != spirv::getTargetEnvAttrName();
328-
}));
329+
});
329330
dictKeyValues.emplace_back(builder.getStringAttr("iree.spirv.features"),
330331
builder.getStrArrayAttr(queries));
331332
variantOp.setTargetAttr(IREE::HAL::ExecutableTargetAttr::get(

compiler/src/iree/compiler/Dialect/Stream/Transforms/ScheduleAllocation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ static void computeRegionValueAliases(Operation *regionOp,
102102

103103
// Filter out to only resource results - some regions may return additional
104104
// things like stream.async.execute returning a timepoint.
105-
auto resourceResults = llvm::to_vector_of<OpResult>(
106-
llvm::make_filter_range(regionOp->getResults(), [](OpResult result) {
105+
auto resourceResults =
106+
llvm::filter_to_vector(regionOp->getResults(), [](OpResult result) {
107107
return llvm::isa<IREE::Stream::ResourceType>(result.getType());
108-
}));
108+
});
109109

110110
// Start with outputs so that we handle tied values that may lead all the way
111111
// back up the chain to the stream inputs.
@@ -1145,12 +1145,12 @@ static std::optional<ConstantAllocation>
11451145
extractConstantsWithLifetime(IREE::Stream::AsyncExecuteOp executeOp,
11461146
IREE::Stream::Lifetime lifetime,
11471147
OpBuilder &externalBuilder) {
1148-
auto constantOps = llvm::to_vector(llvm::make_filter_range(
1148+
auto constantOps = llvm::filter_to_vector(
11491149
executeOp.getOps<IREE::Stream::AsyncConstantOp>(),
11501150
[&](IREE::Stream::AsyncConstantOp op) {
11511151
return cast<IREE::Stream::ResourceType>(op.getResult().getType())
11521152
.getLifetime() == lifetime;
1153-
}));
1153+
});
11541154
if (constantOps.empty())
11551155
return {};
11561156

0 commit comments

Comments
 (0)