mirror of
https://github.com/ROCm/ROCm.git
synced 2026-04-05 03:01:17 -04:00
MLIR current only supports a custom inlining interface per dialect, so we cannot change the inlining decision of `func.func`. https://discourse.llvm.org/t/avoid-inlining-some-functions-using-the-func-dialect/69830/3 Could revert it back once they've designed a better inliner interface. Inlining attributes will be implemented in the next PR since this PR is already huge.
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include "mlir/Pass/Pass.h"
|
|
#include "triton/Analysis/AxisInfo.h"
|
|
#include "triton/Analysis/Utility.h"
|
|
|
|
using namespace mlir;
|
|
|
|
namespace {
|
|
|
|
struct TestAxisInfoPass
|
|
: public PassWrapper<TestAxisInfoPass, OperationPass<triton::FuncOp>> {
|
|
|
|
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestAxisInfoPass);
|
|
|
|
StringRef getArgument() const final { return "test-print-alignment"; }
|
|
StringRef getDescription() const final {
|
|
return "print the result of the alignment analysis pass";
|
|
}
|
|
|
|
void runOnOperation() override {
|
|
Operation *operation = getOperation();
|
|
auto &os = llvm::errs();
|
|
auto opName = SymbolTable::getSymbolName(operation).getValue().str();
|
|
os << "@" << opName << "\n";
|
|
|
|
std::unique_ptr<DataFlowSolver> solver = createDataFlowSolver();
|
|
AxisInfoAnalysis *analysis = solver->load<AxisInfoAnalysis>();
|
|
if (failed(solver->initializeAndRun(operation)))
|
|
return signalPassFailure();
|
|
operation->walk([&](Operation *op) {
|
|
if (op->getNumResults() < 1)
|
|
return;
|
|
for (Value result : op->getResults()) {
|
|
result.print(os);
|
|
os << " => ";
|
|
analysis->getLatticeElement(result)->getValue().print(os);
|
|
os << "\n";
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
namespace mlir {
|
|
namespace test {
|
|
void registerTestAlignmentPass() { PassRegistration<TestAxisInfoPass>(); }
|
|
} // namespace test
|
|
} // namespace mlir
|