diff --git a/lib/Dialect/TorchConversion/Transforms/Passes.cpp b/lib/Dialect/TorchConversion/Transforms/Passes.cpp index 4cdadb578..42ec495d9 100644 --- a/lib/Dialect/TorchConversion/Transforms/Passes.cpp +++ b/lib/Dialect/TorchConversion/Transforms/Passes.cpp @@ -166,5 +166,12 @@ void TorchConversion::createTorchBackendToStablehloBackendPipeline( pm.addNestedPass( stablehlo::createStablehloCanonicalizeDynamismPass()); pm.addNestedPass(createCanonicalizerPass()); + + // Legalize deprecated ops to Stablehlo ops + stablehlo::StablehloLegalizeDeprecatedOpsPassOptions stablehloOptions; + stablehloOptions.failOnUnusedOps = false; + pm.addNestedPass( + stablehlo::createStablehloLegalizeDeprecatedOpsPass(stablehloOptions)); + pm.addPass(createCanonicalizerPass()); } #endif diff --git a/lib/InitAll.cpp b/lib/InitAll.cpp index 7ade22b05..c9638c835 100644 --- a/lib/InitAll.cpp +++ b/lib/InitAll.cpp @@ -67,6 +67,8 @@ void mlir::torch::registerAllPasses() { mlir::stablehlo::registerStablehloAggressiveSimplificationPass(); mlir::stablehlo::registerStablehloRefineShapesPass(); mlir::stablehlo::registerStablehloConvertToSignlessPass(); + mlir::stablehlo::registerShapeLegalizeToStablehloPass(); + mlir::stablehlo::registerStablehloLegalizeDeprecatedOpsPass(); #endif #ifdef TORCH_MLIR_ENABLE_REFBACKEND