Conversion from MLIR to tensorflow GraphDef

Today it is possible to convert TF ConcreteFunction and GraphDef objects into MLIR code that can be printed. It’s part of the standard Python library, and seems to work pretty well.

But I can’t find a way of transforming back a piece of MLIR code in a GraphDef object. Is there a way to do so?

My objective would be to perform a few MLIR-based transformations in a tool of mine before moving back to the TF compilation flow.

ADDENDUM: while digging further, I have found that some people use tools tf-opt and tf-mlir-translate. But for some reason I can’t find them in the python-based tensorflow installation (installation done using pip). Can someone tell me where I can find those tools?

Best regards,
Dumitru

There is no Python API for this I believe, but tf-mlir-translate has a -mlir2graphdef option. You can look into the C++ API used there if you want to plumb this in another tool.

Can you tell me where I can find tf-mlir-translate?

bazelisk build //tensorflow/compiler/mlir:tf-mlir-translate

1 Like