Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace mlir::iree_compiler::IREE::Encoding {
namespace {

// Used for custom printing support.
struct EncodingOpAsmInterface : public OpAsmDialectInterface {
struct EncodingOpAsmInterface : OpAsmDialectInterface {
using OpAsmDialectInterface::OpAsmDialectInterface;
// Hooks for getting an alias identifier alias for a given symbol, that is
// not necessarily a part of this dialect. The identifier is used in place
Expand All @@ -45,7 +45,7 @@ struct EncodingOpAsmInterface : public OpAsmDialectInterface {
};

// Used to control inlining behavior.
struct EncodingInlinerInterface : public DialectInlinerInterface {
struct EncodingInlinerInterface : DialectInlinerInterface {
using DialectInlinerInterface::DialectInlinerInterface;

bool isLegalToInline(Operation *call, Operation *callable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ namespace {
///
/// This is expected to improve performance because we can use DMA
/// functionalities for the fill, instead of dispatching kernels.
struct ConvertLinalgFillPattern final
: public OpRewritePattern<linalg::FillOp> {
struct ConvertLinalgFillPattern final : OpRewritePattern<linalg::FillOp> {
using Base::Base;

LogicalResult matchAndRewrite(linalg::FillOp fillOp,
Expand All @@ -49,7 +48,7 @@ struct ConvertLinalgFillPattern final

/// Convert tensor.insert_slice ops into flow.tensor.update ops where possible.
struct ConvertTensorInsertSlicePattern
: public OpRewritePattern<tensor::InsertSliceOp> {
: OpRewritePattern<tensor::InsertSliceOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::InsertSliceOp insertOp,
PatternRewriter &rewriter) const override {
Expand All @@ -58,7 +57,7 @@ struct ConvertTensorInsertSlicePattern
};

/// Convert tensor.insert ops into flow.tensor.store ops where possible.
struct ConvertTensorInsertPattern : public OpRewritePattern<tensor::InsertOp> {
struct ConvertTensorInsertPattern : OpRewritePattern<tensor::InsertOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::InsertOp insertOp,
PatternRewriter &rewriter) const override {
Expand All @@ -74,16 +73,15 @@ struct ConvertTensorInsertPattern : public OpRewritePattern<tensor::InsertOp> {

/// Convert tensor.extract_slice ops into flow.tensor.slice ops where possible.
struct ConvertTensorExtractSlicePattern
: public OpRewritePattern<tensor::ExtractSliceOp> {
: OpRewritePattern<tensor::ExtractSliceOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::ExtractSliceOp sliceOp,
PatternRewriter &rewriter) const override {
return convertExtractSliceOpToFlowSliceOp(rewriter, sliceOp);
}
};

struct ConvertTensorExtractPattern
: public OpRewritePattern<tensor::ExtractOp> {
struct ConvertTensorExtractPattern : OpRewritePattern<tensor::ExtractOp> {
using Base::Base;

LogicalResult matchAndRewrite(tensor::ExtractOp op,
Expand All @@ -97,8 +95,7 @@ struct ConvertTensorExtractPattern
}
};

struct ConvertTensorExtBitcastPattern
: public OpRewritePattern<TensorExt::BitCastOp> {
struct ConvertTensorExtBitcastPattern : OpRewritePattern<TensorExt::BitCastOp> {
using Base::Base;
LogicalResult matchAndRewrite(TensorExt::BitCastOp op,
PatternRewriter &rewriter) const override {
Expand All @@ -112,8 +109,7 @@ struct ConvertTensorExtBitcastPattern
}
};

struct ConvertTensorBitcastPattern
: public OpRewritePattern<tensor::BitcastOp> {
struct ConvertTensorBitcastPattern : OpRewritePattern<tensor::BitcastOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::BitcastOp op,
PatternRewriter &rewriter) const override {
Expand All @@ -129,7 +125,7 @@ struct ConvertTensorBitcastPattern
}
};

struct ConvertTensorCastPattern : public OpRewritePattern<tensor::CastOp> {
struct ConvertTensorCastPattern : OpRewritePattern<tensor::CastOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::CastOp op,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -193,7 +189,7 @@ struct ConvertTensorCastPattern : public OpRewritePattern<tensor::CastOp> {
}
};

struct ConvertTensorConcatPattern : public OpRewritePattern<tensor::ConcatOp> {
struct ConvertTensorConcatPattern : OpRewritePattern<tensor::ConcatOp> {
using Base::Base;

LogicalResult matchAndRewrite(tensor::ConcatOp concatOp,
Expand Down Expand Up @@ -276,7 +272,7 @@ struct ConvertTensorConcatPattern : public OpRewritePattern<tensor::ConcatOp> {
};

struct ConvertTensorFromElementsPattern
: public OpRewritePattern<tensor::FromElementsOp> {
: OpRewritePattern<tensor::FromElementsOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::FromElementsOp op,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -337,7 +333,7 @@ static SmallVector<Value> getDynamicTensorSizes(OpBuilder &builder,

/// Convert tensor.reshape ops into flow.tensor.reshape ops where possible.
struct ConvertTensorDialectReshapeOpPattern
: public OpRewritePattern<tensor::ReshapeOp> {
: OpRewritePattern<tensor::ReshapeOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::ReshapeOp op,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -383,7 +379,7 @@ struct ConvertTensorDialectReshapeOpPattern
/// Converts linalg.tensor_reshape operations into flow.tensor.reshape
/// operations.
template <typename TensorReshapeOp>
struct ConvertTensorReshapePattern : public OpRewritePattern<TensorReshapeOp> {
struct ConvertTensorReshapePattern : OpRewritePattern<TensorReshapeOp> {
using OpRewritePattern<TensorReshapeOp>::OpRewritePattern;

LogicalResult matchAndRewrite(TensorReshapeOp reshapeOp,
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/iree/compiler/Dialect/Flow/IR/FlowDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace mlir::iree_compiler::IREE::Flow {
namespace {

// Used to control inlining behavior.
struct FlowInlinerInterface : public DialectInlinerInterface {
struct FlowInlinerInterface : DialectInlinerInterface {
using DialectInlinerInterface::DialectInlinerInterface;

bool isLegalToInline(Operation *call, Operation *callable,
Expand All @@ -45,7 +45,7 @@ struct FlowInlinerInterface : public DialectInlinerInterface {
}
};

struct FlowFolderInterface : public DialectFoldInterface {
struct FlowFolderInterface : DialectFoldInterface {
using DialectFoldInterface::DialectFoldInterface;

bool shouldMaterializeInto(Region *region) const override {
Expand Down
35 changes: 16 additions & 19 deletions compiler/src/iree/compiler/Dialect/Flow/IR/FlowOpFolders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace {
// This is to support ops that are "pure" but can't be marked as such because
// the MLIR CSE pass would deduplicate them.
template <typename Op>
struct ElideUnusedOp : public OpRewritePattern<Op> {
struct ElideUnusedOp : OpRewritePattern<Op> {
using OpRewritePattern<Op>::OpRewritePattern;
LogicalResult matchAndRewrite(Op op,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -88,7 +88,7 @@ static bool isTensorResultZeroElements(Value value) {
}

template <typename Op, int OperandIdx, int ResultIdx = 0>
struct ReplaceOpIfTensorOperandZeroElements : public OpRewritePattern<Op> {
struct ReplaceOpIfTensorOperandZeroElements : OpRewritePattern<Op> {
using OpRewritePattern<Op>::OpRewritePattern;
LogicalResult matchAndRewrite(Op op,
PatternRewriter &rewriter) const override {
Expand All @@ -105,7 +105,7 @@ struct ReplaceOpIfTensorOperandZeroElements : public OpRewritePattern<Op> {
};

template <typename Op, int ResultIdx>
struct ReplaceOpIfTensorResultZeroElements : public OpRewritePattern<Op> {
struct ReplaceOpIfTensorResultZeroElements : OpRewritePattern<Op> {
using OpRewritePattern<Op>::OpRewritePattern;
LogicalResult matchAndRewrite(Op op,
PatternRewriter &rewriter) const override {
Expand All @@ -121,7 +121,7 @@ struct ReplaceOpIfTensorResultZeroElements : public OpRewritePattern<Op> {
};

template <typename Op, int OperandIdx, int ResultIdx = 0>
struct ReplaceOpIfTensorOperandEmpty : public OpRewritePattern<Op> {
struct ReplaceOpIfTensorOperandEmpty : OpRewritePattern<Op> {
using OpRewritePattern<Op>::OpRewritePattern;
LogicalResult matchAndRewrite(Op op,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -211,7 +211,7 @@ dedupAndGetOldToNewPosMapping(ValueRange values) {
}

struct ReplaceDispatchResultIfZeroElements
: public OpRewritePattern<DispatchWorkgroupsOp> {
: OpRewritePattern<DispatchWorkgroupsOp> {
using Base::Base;
LogicalResult matchAndRewrite(DispatchWorkgroupsOp op,
PatternRewriter &rewriter) const override {
Expand All @@ -236,8 +236,7 @@ struct ReplaceDispatchResultIfZeroElements

/// Deduplicate redundant workload values of a dispatch.workgroups op. This
/// requires modifying the `count` region of the op to match the new workloads.
struct ElideRedundantWorkloadValues
: public OpRewritePattern<DispatchWorkgroupsOp> {
struct ElideRedundantWorkloadValues : OpRewritePattern<DispatchWorkgroupsOp> {
using Base::Base;
LogicalResult matchAndRewrite(DispatchWorkgroupsOp op,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -393,8 +392,7 @@ OpFoldResult DispatchTieShapeOp::fold(FoldAdaptor operands) {

namespace {

struct DeduplicateDispatchEntryRefs final
: public OpRewritePattern<DispatchOp> {
struct DeduplicateDispatchEntryRefs final : OpRewritePattern<DispatchOp> {
using Base::Base;
LogicalResult matchAndRewrite(DispatchOp dispatchOp,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -456,8 +454,7 @@ OpFoldResult TensorDynamicConstantOp::fold(FoldAdaptor operands) {

namespace {

struct ExpandDynamicShapeConstant
: public OpRewritePattern<TensorDynamicConstantOp> {
struct ExpandDynamicShapeConstant : OpRewritePattern<TensorDynamicConstantOp> {
using Base::Base;
LogicalResult matchAndRewrite(TensorDynamicConstantOp op,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -532,7 +529,7 @@ namespace {
// source. This prevents big useless chains and makes it easier to track the
// original storage for the tensor.
template <typename CastOpTy>
struct FlattenTensorCastLikeChain : public OpRewritePattern<CastOpTy> {
struct FlattenTensorCastLikeChain : OpRewritePattern<CastOpTy> {
using OpRewritePattern<CastOpTy>::OpRewritePattern;
LogicalResult matchAndRewrite(CastOpTy reshapeOp,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -572,7 +569,7 @@ struct FlattenTensorCastLikeChain : public OpRewritePattern<CastOpTy> {
}
};

struct ResolveShapedRank : public OpRewritePattern<tensor::RankOp> {
struct ResolveShapedRank : OpRewritePattern<tensor::RankOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::RankOp op,
PatternRewriter &rewriter) const override {
Expand All @@ -583,7 +580,7 @@ struct ResolveShapedRank : public OpRewritePattern<tensor::RankOp> {
}
};

struct ResolveShapedDim : public OpRewritePattern<tensor::DimOp> {
struct ResolveShapedDim : OpRewritePattern<tensor::DimOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::DimOp op,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -683,7 +680,7 @@ namespace {

// Replace `flow.tensor.splat`-`flow.tensor.load` op-pairs by the input
// primitive value for the splat op.
struct FoldSplatLoadIntoPrimitive : public OpRewritePattern<TensorLoadOp> {
struct FoldSplatLoadIntoPrimitive : OpRewritePattern<TensorLoadOp> {
using Base::Base;
LogicalResult matchAndRewrite(TensorLoadOp loadOp,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -757,7 +754,7 @@ void TensorEmptyOp::getCanonicalizationPatterns(RewritePatternSet &results,

namespace {

struct FoldSplatReshapeIntoSplat : public OpRewritePattern<TensorReshapeOp> {
struct FoldSplatReshapeIntoSplat : OpRewritePattern<TensorReshapeOp> {
using Base::Base;
LogicalResult matchAndRewrite(TensorReshapeOp reshapeOp,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -882,7 +879,7 @@ namespace {
// is transferred to the same context it's already on. This does not look across
// control flow edges or globals and is mostly for simplifying IR that may come
// in with a transfer on every single tensor.
struct ElideRedundantTransfer : public OpRewritePattern<TensorTransferOp> {
struct ElideRedundantTransfer : OpRewritePattern<TensorTransferOp> {
using Base::Base;
LogicalResult matchAndRewrite(TensorTransferOp op,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -1074,7 +1071,7 @@ namespace {

// When the target tensor is a result of a tensor.cast operation, the op needs
// to be updated to use the source of the cast as the target tensor.
struct FoldTensorUpdateOpWithCasts : public OpRewritePattern<TensorUpdateOp> {
struct FoldTensorUpdateOpWithCasts : OpRewritePattern<TensorUpdateOp> {
using Base::Base;
LogicalResult matchAndRewrite(TensorUpdateOp updateOp,
PatternRewriter &rewriter) const override {
Expand Down Expand Up @@ -1103,7 +1100,7 @@ struct FoldTensorUpdateOpWithCasts : public OpRewritePattern<TensorUpdateOp> {
};

struct ReplaceOpIfTensorUpdateOperandZeroElements
: public OpRewritePattern<TensorUpdateOp> {
: OpRewritePattern<TensorUpdateOp> {
using Base::Base;
LogicalResult matchAndRewrite(TensorUpdateOp op,
PatternRewriter &rewriter) const override {
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/iree/compiler/Dialect/Flow/IR/FlowOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,7 @@ bool dropUnusedAndRedundantDispatchRegionResults(
return true;
}

struct DispatchRegionDropUnusedResults
: public OpRewritePattern<DispatchRegionOp> {
struct DispatchRegionDropUnusedResults : OpRewritePattern<DispatchRegionOp> {
using Base::Base;

LogicalResult matchAndRewrite(DispatchRegionOp regionOp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,7 @@ static std::string summarizeDispatchRegion(Region &region) {
}

struct AnnotateDispatchesPass
: public IREE::Flow::impl::AnnotateDispatchesPassBase<
AnnotateDispatchesPass> {
: IREE::Flow::impl::AnnotateDispatchesPassBase<AnnotateDispatchesPass> {

void runOnOperation() override {
DenseMap<Attribute, SymbolRefAttr> entryPointRefReplacements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static std::optional<SmallVector<OpFoldResult>> getDefiningMixedSizes(Value v) {
return {};
}

struct FoldFullInsertSlice : public OpRewritePattern<tensor::InsertSliceOp> {
struct FoldFullInsertSlice : OpRewritePattern<tensor::InsertSliceOp> {
using Base::Base;

LogicalResult matchAndRewrite(tensor::InsertSliceOp insertSliceOp,
Expand Down Expand Up @@ -103,7 +103,7 @@ class AffineApplyLowering : public OpRewritePattern<affine::AffineApplyOp> {
};

/// Canonicalize operations in nested regions.
struct CanonicalizePass : public impl::CanonicalizePassBase<CanonicalizePass> {
struct CanonicalizePass : impl::CanonicalizePassBase<CanonicalizePass> {
using IREE::Flow::impl::CanonicalizePassBase<
CanonicalizePass>::CanonicalizePassBase;
/// Initialize the canonicalizer by building the set of patterns used during
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ static void captureDims(scf::ForOp forOp) {
}

struct CaptureDynamicDimsPass
: public IREE::Flow::impl::CaptureDynamicDimsPassBase<
CaptureDynamicDimsPass> {
: IREE::Flow::impl::CaptureDynamicDimsPassBase<CaptureDynamicDimsPass> {
void runOnOperation() override {
getOperation()->walk([&](scf::ForOp forOp) { captureDims(forOp); });
getOperation()->walk([&](IREE::Flow::DispatchWorkgroupsOp dispatchOp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ namespace mlir::iree_compiler::IREE::Flow {
namespace {

struct CleanupTensorShapesPass
: public IREE::Flow::impl::CleanupTensorShapesPassBase<
CleanupTensorShapesPass> {
: IREE::Flow::impl::CleanupTensorShapesPassBase<CleanupTensorShapesPass> {
void runOnOperation() override {
// Walk ops and ensure we no longer have any tensor shape queries.
// If we come across any shape witness ops we can erase those.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace {

// Pass to test conversion to flow patterns.
struct ConvertToFlowPass
: public IREE::Flow::impl::ConvertToFlowPassBase<ConvertToFlowPass> {
: IREE::Flow::impl::ConvertToFlowPassBase<ConvertToFlowPass> {
void runOnOperation() override {
MLIRContext *context = &getContext();
RewritePatternSet convertToFlowPatterns(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ createEntryPointBenchmarkFunc(mlir::ModuleOp moduleOp,
// attribute from the old functions.
// The input are provided using util.globals.
struct ExportBenchmarkFuncsPass
: public IREE::Flow::impl::ExportBenchmarkFuncsPassBase<
ExportBenchmarkFuncsPass> {
: IREE::Flow::impl::ExportBenchmarkFuncsPassBase<ExportBenchmarkFuncsPass> {
void runOnOperation() override {
mlir::ModuleOp moduleOp = getOperation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static bool shouldBeConvertedToFlowTensorOp(tensor::EmptyOp emptyTensorOp) {
namespace {

/// Converts an tensor.empty() op to `flow.tensor.splat` op.
struct RewriteTensorEmptyToSplat : public OpRewritePattern<tensor::EmptyOp> {
struct RewriteTensorEmptyToSplat : OpRewritePattern<tensor::EmptyOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::EmptyOp emptyTensorOp,
PatternRewriter &rewriter) const override {
Expand All @@ -66,7 +66,7 @@ struct RewriteTensorEmptyToSplat : public OpRewritePattern<tensor::EmptyOp> {
};

/// Converts an tensor.empty() op to `flow.tensor.empty` op.
struct RewriteTensorEmptyToEmpty : public OpRewritePattern<tensor::EmptyOp> {
struct RewriteTensorEmptyToEmpty : OpRewritePattern<tensor::EmptyOp> {
using Base::Base;
LogicalResult matchAndRewrite(tensor::EmptyOp emptyTensorOp,
PatternRewriter &rewriter) const override {
Expand All @@ -82,7 +82,7 @@ struct RewriteTensorEmptyToEmpty : public OpRewritePattern<tensor::EmptyOp> {

/// Pass to invoke the pattern.
struct InitializeEmptyTensorsPass
: public IREE::Flow::impl::InitializeEmptyTensorsPassBase<
: IREE::Flow::impl::InitializeEmptyTensorsPassBase<
InitializeEmptyTensorsPass> {
using IREE::Flow::impl::InitializeEmptyTensorsPassBase<
InitializeEmptyTensorsPass>::InitializeEmptyTensorsPassBase;
Expand Down
Loading
Loading