torch-mlir icon indicating copy to clipboard operation
torch-mlir copied to clipboard

Reduce MHLO #ifdefs

Open silvasean opened this issue 2 years ago • 1 comments

We try to avoid using #ifdefs because they make it impossible to test all the configurations easily.

I noticed two in TorchToMhlo that can be removed.

TORCH_MLIR_ENABLE_MHLO_STATIC_SHAPE TORCH_MLIR_ENABLE_MHLO_TRUNC_DIMSIZE_TO_I32

https://github.com/llvm/torch-mlir/blob/9d6ee48661cefa677950bcd262fe2824a4fa9d17/lib/Conversion/TorchToMhlo/Basic.cpp#L412

We should add those as pass options to the convert-torch-to-mhlo pass, and pass them down to the patterns that need them. (see here for how to add pass options: https://mlir.llvm.org/docs/PassManagement/#declarative-pass-specification)

cc @ZihengJiang @fortianyou

silvasean avatar Aug 15 '22 22:08 silvasean

Sure! This is a good suggestion. I will try it out recently.

tanyokwok avatar Aug 16 '22 14:08 tanyokwok

Fixed in https://github.com/llvm/torch-mlir/pull/1315

silvasean avatar Oct 07 '22 13:10 silvasean