Link necessary op interface implementations (#3364)

This patch adds two `memref` passes to `torch-mlir-opt`, which already
occur in the pass pipeline
`torch-backend-to-linalg-on-tensors-backend-pipeline`. Additionally,
necessary op interface external models are included to address issue
#3352.
pull/3414/head
zjgarvey 2024-06-03 19:43:28 -05:00 committed by GitHub
parent 0a6861b1e8
commit 56d21cba62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,9 @@ namespace torch {
// Registers all dialects that this project produces and any dependencies.
void registerAllDialects(mlir::DialectRegistry &registry);
// Registers all necessary dialect extensions for this project
void registerAllExtensions(mlir::DialectRegistry &registry);
// Registers dialects that may be needed to parse torch-mlir inputs and
// test cases.
void registerOptionalInputDialects(mlir::DialectRegistry &registry);

View File

@ -13,6 +13,7 @@ set(LinkedLibs
MLIRMemRefDialect
MLIRSCFDialect
MLIRTensorDialect
MLIRTensorInferTypeOpInterfaceImpl
MLIRTosaDialect
MLIRSupport

View File

@ -17,6 +17,7 @@
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.h"
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
#include "mlir/IR/Dialect.h"
#include "torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorDialect.h"
@ -39,7 +40,11 @@ void mlir::torch::registerAllDialects(mlir::DialectRegistry &registry) {
registry.insert<mlir::torch::Torch::TorchDialect>();
registry.insert<mlir::torch::TorchConversion::TorchConversionDialect>();
registry.insert<mlir::torch::TMTensor::TMTensorDialect>();
}
void mlir::torch::registerAllExtensions(mlir::DialectRegistry &registry) {
mlir::func::registerInlinerExtension(registry);
tensor::registerInferTypeOpInterfaceExternalModels(registry);
}
// TODO: Break this up when backends are separated.

View File

@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/MemRef/Transforms/Passes.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Tools/mlir-opt/MlirOptMain.h"
@ -33,8 +34,13 @@ int main(int argc, char **argv) {
registerStripDebugInfoPass();
registerSymbolDCEPass();
// memref passes used in torch-backend-to-linalg-on-tensors-backend-pipeline
memref::registerExpandOpsPass();
memref::registerResolveShapedTypeResultDimsPass();
DialectRegistry registry;
mlir::torch::registerAllDialects(registry);
mlir::torch::registerAllExtensions(registry);
mlir::torch::registerOptionalInputDialects(registry);
#ifdef TORCH_MLIR_ENABLE_STABLEHLO