-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mpact][tools] set up the mpact-opt tool
- Loading branch information
Peiming Liu
committed
May 23, 2024
1 parent
983a8d8
commit 13603e4
Showing
7 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
mpact_venv/ | ||
*_venv/ | ||
__pycache__ | ||
/build/ | ||
/build*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(mpact-opt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
add_llvm_executable(mpact-opt mpact_opt.cpp) | ||
|
||
set(dependency_libraries) | ||
if(TORCH_MLIR_ENABLE_STABLEHLO) | ||
list(APPEND dependency_libraries StablehloRegister) | ||
endif() | ||
|
||
target_link_libraries(mpact-opt PRIVATE | ||
MLIROptLib | ||
MLIRTransforms | ||
TorchMLIRInitAll | ||
TorchMLIRTorchDialect | ||
TorchMLIRTorchPasses | ||
${dependency_libraries} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//===- mpact-opt.cpp - MLIR Optimizer Driver -------------------------===// | ||
// | ||
// Part of the MPACT 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 | ||
// Also available under a BSD-style license. See LICENSE. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Dialect/SCF/IR/SCF.h" | ||
#include "mlir/Dialect/Tensor/IR/Tensor.h" | ||
#include "mlir/Tools/mlir-opt/MlirOptMain.h" | ||
#include "mlir/Transforms/Passes.h" | ||
#include "torch-mlir/InitAll.h" | ||
|
||
#ifdef TORCH_MLIR_ENABLE_STABLEHLO | ||
#include "stablehlo/dialect/Register.h" | ||
#endif | ||
|
||
using namespace mlir; | ||
|
||
int main(int argc, char **argv) { | ||
mlir::torch::registerAllPasses(); | ||
|
||
// Core Transforms | ||
registerCanonicalizerPass(); | ||
registerCSEPass(); | ||
registerInlinerPass(); | ||
registerLocationSnapshotPass(); | ||
registerLoopInvariantCodeMotionPass(); | ||
registerPrintOpStatsPass(); | ||
registerViewOpGraphPass(); | ||
registerStripDebugInfoPass(); | ||
registerSymbolDCEPass(); | ||
|
||
DialectRegistry registry; | ||
mlir::torch::registerAllDialects(registry); | ||
mlir::torch::registerOptionalInputDialects(registry); | ||
|
||
#ifdef TORCH_MLIR_ENABLE_STABLEHLO | ||
mlir::stablehlo::registerAllDialects(registry); | ||
#endif | ||
return mlir::asMainReturnCode(mlir::MlirOptMain( | ||
argc, argv, "MLIR modular optimizer driver\n", registry)); | ||
} |