[Mlir-commits] [mlir] [mlir][bytecode] Fix external resource bytecode parsing (PR #97650)

Jeff Niu llvmlistbot at llvm.org
Wed Jul 3 15:30:54 PDT 2024


https://github.com/Mogball created https://github.com/llvm/llvm-project/pull/97650

The key was being dropped for external resources because they aren't present in the dialect resource name mapper.

>From e5d0191770d40338dfe43a4e2c55046487b182e1 Mon Sep 17 00:00:00 2001
From: Mogball <jeff at modular.com>
Date: Wed, 3 Jul 2024 22:28:59 +0000
Subject: [PATCH] [mlir][bytecode] Fix external resource bytecode parsing

The key was being dropped for external resources because they aren't
present in the dialect resource name mapper.
---
 mlir/lib/Bytecode/Reader/BytecodeReader.cpp |  2 +-
 mlir/test/Bytecode/external_resources.mlir  | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 mlir/test/Bytecode/external_resources.mlir

diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index dd1e4abaea166..5b34ba5a65ff8 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -707,7 +707,7 @@ LogicalResult ResourceSectionReader::initialize(
     auto resolveKey = [&](StringRef key) -> StringRef {
       auto it = dialectResourceHandleRenamingMap.find(key);
       if (it == dialectResourceHandleRenamingMap.end())
-        return "";
+        return key;
       return it->second;
     };
 
diff --git a/mlir/test/Bytecode/external_resources.mlir b/mlir/test/Bytecode/external_resources.mlir
new file mode 100644
index 0000000000000..722c108f687e2
--- /dev/null
+++ b/mlir/test/Bytecode/external_resources.mlir
@@ -0,0 +1,19 @@
+// RUN: mlir-opt %s -emit-bytecode | mlir-opt
+
+module {
+}
+
+{-#
+  // CHECK: external_resources
+  external_resources: {
+    // CHECK-NEXT: mlir_reproducer
+    mlir_reproducer: {
+      // CHECK-NEXT: pipeline: "builtin.module(func.func(canonicalize,cse))"
+      pipeline: "builtin.module(func.func(canonicalize,cse))",
+      // CHECK-NEXT: disable_threading: true
+      disable_threading: true,
+      // CHECK-NEXT: verify_each: true
+      verify_each: true
+    }
+  }
+#-}



More information about the Mlir-commits mailing list