[Stablehlo] legalize deprecated ops to stablehlo ops (#3543)

pull/3550/head
Yuanqiang Liu 2024-07-17 00:05:11 +08:00 committed by GitHub
parent e5d1677894
commit 714270a922
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View File

@ -166,5 +166,12 @@ void TorchConversion::createTorchBackendToStablehloBackendPipeline(
pm.addNestedPass<func::FuncOp>( pm.addNestedPass<func::FuncOp>(
stablehlo::createStablehloCanonicalizeDynamismPass()); stablehlo::createStablehloCanonicalizeDynamismPass());
pm.addNestedPass<func::FuncOp>(createCanonicalizerPass()); pm.addNestedPass<func::FuncOp>(createCanonicalizerPass());
// Legalize deprecated ops to Stablehlo ops
stablehlo::StablehloLegalizeDeprecatedOpsPassOptions stablehloOptions;
stablehloOptions.failOnUnusedOps = false;
pm.addNestedPass<func::FuncOp>(
stablehlo::createStablehloLegalizeDeprecatedOpsPass(stablehloOptions));
pm.addPass(createCanonicalizerPass());
} }
#endif #endif

View File

@ -67,6 +67,8 @@ void mlir::torch::registerAllPasses() {
mlir::stablehlo::registerStablehloAggressiveSimplificationPass(); mlir::stablehlo::registerStablehloAggressiveSimplificationPass();
mlir::stablehlo::registerStablehloRefineShapesPass(); mlir::stablehlo::registerStablehloRefineShapesPass();
mlir::stablehlo::registerStablehloConvertToSignlessPass(); mlir::stablehlo::registerStablehloConvertToSignlessPass();
mlir::stablehlo::registerShapeLegalizeToStablehloPass();
mlir::stablehlo::registerStablehloLegalizeDeprecatedOpsPass();
#endif #endif
#ifdef TORCH_MLIR_ENABLE_REFBACKEND #ifdef TORCH_MLIR_ENABLE_REFBACKEND