We are writing a just in time compiler. As part of this we are attempting to hide the compilation overhead by compiling multiple MLIR graphs in different threads at the same time. As far as I can tell this means we need an MLIRContext
per compilation thread (if only to ensure that debug info doesn’t get interleaved). We also have a caching layer - if we receive the same module twice we reuse the executable from the first compilation. The caching layer requires graph hashing and graph comparison. The comparison and hashing from mlir::OperationEquivalence
appears to depend on the MLIRContext
the module was built in (this is because new copies of the dialects are loaded for each MLIRContext
). So we’ve been forced to write our own comparison and hashing layer (obviously this is very similar to mlir::OperationEquivalence
). I have a couple of questions:
- Is there a better way of doing the graph comparison? Can I somehow use
mlir::OperationEquivalence
with graphs from different contexts? - Re-loading all the dialects for each thread seems inefficient - is there a way to re-use this work for multiple
MLIRContext
s?