The `tileAndFuseLinalgOps` is a legacy approach for tiling + fusion of Linalg operations. Since it was also intended to work on operations with buffer operands, this method had fairly complex logic to make sure tile and fuse was correct even with side-effecting linalg ops. While complex, it still wasnt robust enough. This patch deprecates this method and thereby deprecating the tiling + fusion method for ops with buffer semantics. Note that the core transformation to do fusion of a producer with a tiled consumer still exists. The deprecation here only removes methods that auto-magically tried to tile and fuse correctly in presence of side-effects. The `tileAndFuseLinalgOps` also works with operations with tensor semantics. There are at least two other ways the same functionality exists. 1) The `tileConsumerAndFuseProducers` method. This does a similar transformation, but using a slightly different logic to automatically figure out the legal tile + fuse code. Note that this is also to be deprecated soon. 2) The prefered way uses the `TilingInterface` for tile + fuse, and relies on the caller to set the tiling options correctly to ensure that the generated code is correct. As proof that (2) is equivalent to the functionality provided by `tileAndFuseLinalgOps`, relevant tests have been moved to use the interface, where the test driver sets the tile sizes appropriately to generate the expected code. Differential Revision: https://reviews.llvm.org/D129901
227 lines
8.2 KiB
C++
227 lines
8.2 KiB
C++
//===- mlir-opt.cpp - MLIR Optimizer Driver -------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Main entry function for mlir-opt for when built as standalone binary.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/IR/AsmState.h"
|
|
#include "mlir/IR/Dialect.h"
|
|
#include "mlir/IR/MLIRContext.h"
|
|
#include "mlir/InitAllDialects.h"
|
|
#include "mlir/InitAllPasses.h"
|
|
#include "mlir/Pass/Pass.h"
|
|
#include "mlir/Pass/PassManager.h"
|
|
#include "mlir/Support/FileUtilities.h"
|
|
#include "mlir/Tools/mlir-opt/MlirOptMain.h"
|
|
#include "llvm/Support/CommandLine.h"
|
|
#include "llvm/Support/InitLLVM.h"
|
|
#include "llvm/Support/SourceMgr.h"
|
|
#include "llvm/Support/ToolOutputFile.h"
|
|
|
|
using namespace llvm;
|
|
using namespace mlir;
|
|
|
|
// Defined in the test directory, no public header.
|
|
namespace mlir {
|
|
void registerConvertToTargetEnvPass();
|
|
void registerCloneTestPasses();
|
|
void registerPassManagerTestPass();
|
|
void registerPrintSpirvAvailabilityPass();
|
|
void registerShapeFunctionTestPasses();
|
|
void registerSideEffectTestPasses();
|
|
void registerSliceAnalysisTestPass();
|
|
void registerSymbolTestPasses();
|
|
void registerRegionTestPasses();
|
|
void registerTestAffineDataCopyPass();
|
|
void registerTestAffineLoopUnswitchingPass();
|
|
void registerTestAllReduceLoweringPass();
|
|
void registerTestFunc();
|
|
void registerTestGpuMemoryPromotionPass();
|
|
void registerTestLoopPermutationPass();
|
|
void registerTestMatchers();
|
|
void registerTestOperationEqualPass();
|
|
void registerTestPrintDefUsePass();
|
|
void registerTestPrintInvalidPass();
|
|
void registerTestPrintNestingPass();
|
|
void registerTestReducer();
|
|
void registerTestSpirvEntryPointABIPass();
|
|
void registerTestSpirvModuleCombinerPass();
|
|
void registerTestTraitsPass();
|
|
void registerTosaTestQuantUtilAPIPass();
|
|
void registerVectorizerTestPass();
|
|
|
|
namespace test {
|
|
void registerConvertCallOpPass();
|
|
void registerInliner();
|
|
void registerMemRefBoundCheck();
|
|
void registerPatternsTestPass();
|
|
void registerSimpleParametricTilingPass();
|
|
void registerTestAffineLoopParametricTilingPass();
|
|
void registerTestAliasAnalysisPass();
|
|
void registerTestBuiltinAttributeInterfaces();
|
|
void registerTestCallGraphPass();
|
|
void registerTestConstantFold();
|
|
void registerTestControlFlowSink();
|
|
void registerTestGpuSerializeToCubinPass();
|
|
void registerTestGpuSerializeToHsacoPass();
|
|
void registerTestDataLayoutQuery();
|
|
void registerTestDeadCodeAnalysisPass();
|
|
void registerTestDecomposeCallGraphTypes();
|
|
void registerTestDiagnosticsPass();
|
|
void registerTestDominancePass();
|
|
void registerTestDynamicPipelinePass();
|
|
void registerTestExpandMathPass();
|
|
void registerTestFooAnalysisPass();
|
|
void registerTestComposeSubView();
|
|
void registerTestMultiBuffering();
|
|
void registerTestIntRangeInference();
|
|
void registerTestIRVisitorsPass();
|
|
void registerTestGenericIRVisitorsPass();
|
|
void registerTestGenericIRVisitorsInterruptPass();
|
|
void registerTestInterfaces();
|
|
void registerTestLastModifiedPass();
|
|
void registerTestLinalgDecomposeOps();
|
|
void registerTestLinalgElementwiseFusion();
|
|
void registerTestLinalgGreedyFusion();
|
|
void registerTestLinalgHoisting();
|
|
void registerTestLinalgTransforms();
|
|
void registerTestLivenessPass();
|
|
void registerTestLoopFusion();
|
|
void registerTestLoopMappingPass();
|
|
void registerTestLoopUnrollingPass();
|
|
void registerTestMatchReductionPass();
|
|
void registerTestMathAlgebraicSimplificationPass();
|
|
void registerTestMathPolynomialApproximationPass();
|
|
void registerTestMemRefDependenceCheck();
|
|
void registerTestMemRefStrideCalculation();
|
|
void registerTestOpaqueLoc();
|
|
void registerTestPadFusion();
|
|
void registerTestPDLByteCodePass();
|
|
void registerTestPDLLPasses();
|
|
void registerTestPreparationPassWithAllowedMemrefResults();
|
|
void registerTestRecursiveTypesPass();
|
|
void registerTestSCFUtilsPass();
|
|
void registerTestSliceAnalysisPass();
|
|
void registerTestTensorTransforms();
|
|
void registerTestTilingInterface();
|
|
void registerTestTransformDialectInterpreterPass();
|
|
void registerTestVectorLowerings();
|
|
} // namespace test
|
|
} // namespace mlir
|
|
|
|
namespace test {
|
|
void registerTestDialect(DialectRegistry &);
|
|
void registerTestTransformDialectExtension(DialectRegistry &);
|
|
} // namespace test
|
|
|
|
#ifdef MLIR_INCLUDE_TESTS
|
|
void registerTestPasses() {
|
|
registerCloneTestPasses();
|
|
registerConvertToTargetEnvPass();
|
|
registerPassManagerTestPass();
|
|
registerPrintSpirvAvailabilityPass();
|
|
registerShapeFunctionTestPasses();
|
|
registerSideEffectTestPasses();
|
|
registerSliceAnalysisTestPass();
|
|
registerSymbolTestPasses();
|
|
registerRegionTestPasses();
|
|
registerTestAffineDataCopyPass();
|
|
registerTestAffineLoopUnswitchingPass();
|
|
registerTestAllReduceLoweringPass();
|
|
registerTestFunc();
|
|
registerTestGpuMemoryPromotionPass();
|
|
registerTestLoopPermutationPass();
|
|
registerTestMatchers();
|
|
registerTestOperationEqualPass();
|
|
registerTestPrintDefUsePass();
|
|
registerTestPrintInvalidPass();
|
|
registerTestPrintNestingPass();
|
|
registerTestReducer();
|
|
registerTestSpirvEntryPointABIPass();
|
|
registerTestSpirvModuleCombinerPass();
|
|
registerTestTraitsPass();
|
|
registerVectorizerTestPass();
|
|
registerTosaTestQuantUtilAPIPass();
|
|
|
|
mlir::test::registerConvertCallOpPass();
|
|
mlir::test::registerInliner();
|
|
mlir::test::registerMemRefBoundCheck();
|
|
mlir::test::registerPatternsTestPass();
|
|
mlir::test::registerSimpleParametricTilingPass();
|
|
mlir::test::registerTestAffineLoopParametricTilingPass();
|
|
mlir::test::registerTestAliasAnalysisPass();
|
|
mlir::test::registerTestBuiltinAttributeInterfaces();
|
|
mlir::test::registerTestCallGraphPass();
|
|
mlir::test::registerTestConstantFold();
|
|
mlir::test::registerTestControlFlowSink();
|
|
mlir::test::registerTestDiagnosticsPass();
|
|
#if MLIR_CUDA_CONVERSIONS_ENABLED
|
|
mlir::test::registerTestGpuSerializeToCubinPass();
|
|
#endif
|
|
#if MLIR_ROCM_CONVERSIONS_ENABLED
|
|
mlir::test::registerTestGpuSerializeToHsacoPass();
|
|
#endif
|
|
mlir::test::registerTestDecomposeCallGraphTypes();
|
|
mlir::test::registerTestDataLayoutQuery();
|
|
mlir::test::registerTestDeadCodeAnalysisPass();
|
|
mlir::test::registerTestDominancePass();
|
|
mlir::test::registerTestDynamicPipelinePass();
|
|
mlir::test::registerTestExpandMathPass();
|
|
mlir::test::registerTestFooAnalysisPass();
|
|
mlir::test::registerTestComposeSubView();
|
|
mlir::test::registerTestMultiBuffering();
|
|
mlir::test::registerTestIntRangeInference();
|
|
mlir::test::registerTestIRVisitorsPass();
|
|
mlir::test::registerTestGenericIRVisitorsPass();
|
|
mlir::test::registerTestInterfaces();
|
|
mlir::test::registerTestLastModifiedPass();
|
|
mlir::test::registerTestLinalgDecomposeOps();
|
|
mlir::test::registerTestLinalgElementwiseFusion();
|
|
mlir::test::registerTestLinalgGreedyFusion();
|
|
mlir::test::registerTestLinalgHoisting();
|
|
mlir::test::registerTestLinalgTransforms();
|
|
mlir::test::registerTestLivenessPass();
|
|
mlir::test::registerTestLoopFusion();
|
|
mlir::test::registerTestLoopMappingPass();
|
|
mlir::test::registerTestLoopUnrollingPass();
|
|
mlir::test::registerTestMatchReductionPass();
|
|
mlir::test::registerTestMathAlgebraicSimplificationPass();
|
|
mlir::test::registerTestMathPolynomialApproximationPass();
|
|
mlir::test::registerTestMemRefDependenceCheck();
|
|
mlir::test::registerTestMemRefStrideCalculation();
|
|
mlir::test::registerTestOpaqueLoc();
|
|
mlir::test::registerTestPadFusion();
|
|
mlir::test::registerTestPDLByteCodePass();
|
|
mlir::test::registerTestPDLLPasses();
|
|
mlir::test::registerTestRecursiveTypesPass();
|
|
mlir::test::registerTestSCFUtilsPass();
|
|
mlir::test::registerTestSliceAnalysisPass();
|
|
mlir::test::registerTestTensorTransforms();
|
|
mlir::test::registerTestTilingInterface();
|
|
mlir::test::registerTestTransformDialectInterpreterPass();
|
|
mlir::test::registerTestVectorLowerings();
|
|
}
|
|
#endif
|
|
|
|
int main(int argc, char **argv) {
|
|
registerAllPasses();
|
|
#ifdef MLIR_INCLUDE_TESTS
|
|
registerTestPasses();
|
|
#endif
|
|
DialectRegistry registry;
|
|
registerAllDialects(registry);
|
|
#ifdef MLIR_INCLUDE_TESTS
|
|
::test::registerTestDialect(registry);
|
|
::test::registerTestTransformDialectExtension(registry);
|
|
#endif
|
|
return mlir::asMainReturnCode(
|
|
mlir::MlirOptMain(argc, argv, "MLIR modular optimizer driver\n", registry,
|
|
/*preloadDialectsInContext=*/false));
|
|
}
|