[Mlir-commits] [mlir] [mlir][bytecode] Implements back deployment capability for MLIR dialects (PR #70724)
Matteo Franciolini
llvmlistbot at llvm.org
Mon Oct 30 19:59:30 PDT 2023
================
@@ -1256,6 +1288,21 @@ void BytecodeWriter::writePropertiesSection(EncodingEmitter &emitter) {
LogicalResult mlir::writeBytecodeToFile(Operation *op, raw_ostream &os,
const BytecodeWriterConfig &config) {
+ // Before creating the bytecode writer, give an opportunity to each of the
+ // dialects that registered a target version emission to perform IR
+ // downgrades. Note that it is responsibility of client dialect to handle the
+ // potentially destructive changes that a downgrade function could do to the
+ // IR.
+ for (auto &item : config.getDialectVersionMap()) {
+ Dialect *currentDialect = op->getContext()->getOrLoadDialect(item.getKey());
+ assert(currentDialect &&
+ "version requested on a dialect that could not be loaded");
+ auto *iface = llvm::dyn_cast<BytecodeDialectInterface>(currentDialect);
+ assert(iface && "version requested on a dialect that did not implement a "
+ "`BytecodeDialectInterface`");
+ if (failed(iface->downgradeToVersion(op, *item.getValue())))
+ return failure();
----------------
mfrancio wrote:
Thanks for the feedback. I removed the functionality associated to downgrading constructs, which is now left to the client entirely, and added an example of downgrade as part of the tests. I also modified title and description accordingly.
https://github.com/llvm/llvm-project/pull/70724
More information about the Mlir-commits
mailing list