Compilation of the TF dialect to standard dialect MLIR. Is it possible?

For the past weeks I’ve been trying to use the existing tf-opt and iree-opt tools to convert non-trivial TF specifications (e.g. resnet) downto a sequential executable code (not something meant to execute on top of a specialized run-time or VM). I wanted to use this type of implementation as a baseline.

My impression now is that this is impossible. On every path I try to descend from TF to the standard dialects of the LLVM/MLIR distribution, there are operations that are not handled (e.g. mhlo.reduce_window makes tf-opt --hlo-legalize-to-linalg produce an error, mhlo.pad makes tf-opt --hlo-legalize-to-lhlo produce an error, and in a different post I am directed towards iree, but the example only runs with a vmla target which seems to be a VM, not native code).

My questions:

  1. Is my impression correct?
  2. If not, can anybody point me to a compilation pipeline that works?
  3. If yes, then what would be the compilation pipelines that currently work (involving of course some run-time support)?

Maybe more generally: there exist a flurry of compilation options, but each such option (a lowering or optimization step) makes assumptions on its input and provides guarantees on its output (assumptions that go beyond simple dialect choices). These assumptions and guarantees are almost always implicit, and this makes it difficult to know how the transformations can be combined into pipelines.

I’d be willing to work with you to document these passes, but is anyone willing to provide the raw information?


1 Like