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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jul 3 15:31:22 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Jeff Niu (Mogball)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/97650.diff


2 Files Affected:

- (modified) mlir/lib/Bytecode/Reader/BytecodeReader.cpp (+1-1) 
- (added) mlir/test/Bytecode/external_resources.mlir (+19) 


``````````diff
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
+    }
+  }
+#-}

``````````

</details>


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


More information about the Mlir-commits mailing list