-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reuse dialect registration/loading (#2391)
* CompilerDialects * remove obsolete Accelerator::getOrLoadDialects() * rely on registerDialects() to initialize accelerators * remove non-functional accelerator support from onnx-mlir-reduce * cleaned up CompilerUtils.hpp includes * document loadDialects() * clean up onnx-mlir-opt exit codes Signed-off-by: Soren Lassen <[email protected]>
- Loading branch information
1 parent
d579ce1
commit 760e2c9
Showing
22 changed files
with
164 additions
and
148 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
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
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
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
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
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,48 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
//===------------------------ CompilerDialects.cpp ------------------------===// | ||
|
||
#include "CompilerDialects.hpp" | ||
|
||
#include "src/Dialect/Krnl/KrnlOps.hpp" | ||
#include "src/Dialect/ONNX/ONNXDialect.hpp" | ||
|
||
#include "mlir/InitAllDialects.h" | ||
|
||
using namespace mlir; | ||
|
||
namespace onnx_mlir { | ||
|
||
DialectRegistry registerDialects(ArrayRef<accel::Accelerator::Kind> accels) { | ||
DialectRegistry registry; | ||
|
||
// Note that we cannot consult command line options because they have not yet | ||
// been parsed when registerDialects() is called. | ||
|
||
registry.insert<arith::ArithDialect>(); | ||
registry.insert<linalg::LinalgDialect>(); | ||
registry.insert<affine::AffineDialect>(); | ||
registry.insert<LLVM::LLVMDialect>(); | ||
registry.insert<scf::SCFDialect>(); | ||
registry.insert<func::FuncDialect>(); | ||
registry.insert<vector::VectorDialect>(); | ||
registry.insert<shape::ShapeDialect>(); | ||
registry.insert<math::MathDialect>(); | ||
registry.insert<memref::MemRefDialect>(); | ||
registry.insert<ONNXDialect>(); | ||
registry.insert<KrnlDialect>(); | ||
registry.insert<cf::ControlFlowDialect>(); | ||
|
||
// Initialize accelerator(s) if required. | ||
accel::initAccelerators(accels); | ||
|
||
// Register dialects for accelerators. | ||
for (auto *accel : accel::Accelerator::getAccelerators()) | ||
accel->registerDialects(registry); | ||
|
||
return registry; | ||
} | ||
|
||
} // namespace onnx_mlir |
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,21 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
//===------------------------ CompilerDialects.hpp ------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "src/Accelerators/Accelerator.hpp" | ||
|
||
#include "mlir/IR/DialectRegistry.h" | ||
#include "llvm/ADT/ArrayRef.h" | ||
|
||
namespace onnx_mlir { | ||
|
||
// Adds the mlir and onnx-mlir dialects needed to compile end to end. | ||
// Initializes accelerator(s) if required. | ||
mlir::DialectRegistry registerDialects( | ||
llvm::ArrayRef<accel::Accelerator::Kind> accels); | ||
|
||
} // namespace onnx_mlir |
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
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
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
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
Oops, something went wrong.