1 //===- TestLinalgHoisting.cpp - Test Linalg hoisting functions ------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file implements logic for testing Linalg hoisting functions. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "mlir/Dialect/Affine/IR/AffineOps.h" 14 #include "mlir/Dialect/Func/IR/FuncOps.h" 15 #include "mlir/Dialect/Linalg/IR/Linalg.h" 16 #include "mlir/Dialect/Linalg/Transforms/Hoisting.h" 17 #include "mlir/Pass/Pass.h" 18 19 using namespace mlir; 20 using namespace mlir::linalg; 21 22 namespace { 23 struct TestLinalgHoisting 24 : public PassWrapper<TestLinalgHoisting, OperationPass<FuncOp>> { 25 TestLinalgHoisting() = default; 26 TestLinalgHoisting(const TestLinalgHoisting &pass) : PassWrapper(pass) {} 27 void getDependentDialects(DialectRegistry ®istry) const override { 28 registry.insert<AffineDialect>(); 29 } 30 StringRef getArgument() const final { return "test-linalg-hoisting"; } 31 StringRef getDescription() const final { 32 return "Test Linalg hoisting functions."; 33 } 34 35 void runOnOperation() override; 36 37 Option<bool> testHoistRedundantTransfers{ 38 *this, "test-hoist-redundant-transfers", 39 llvm::cl::desc("Test hoisting transfer_read/transfer_write pairs"), 40 llvm::cl::init(false)}; 41 }; 42 } // namespace 43 44 void TestLinalgHoisting::runOnOperation() { 45 if (testHoistRedundantTransfers) { 46 hoistRedundantVectorTransfers(getOperation()); 47 hoistRedundantVectorTransfersOnTensor(getOperation()); 48 return; 49 } 50 } 51 52 namespace mlir { 53 namespace test { 54 void registerTestLinalgHoisting() { PassRegistration<TestLinalgHoisting>(); } 55 } // namespace test 56 } // namespace mlir 57